Những câu hỏi liên quan
๖ۣۜHả๖ۣۜI
Xem chi tiết
Uyên  Thy
18 tháng 3 2022 lúc 21:05

Tham khảo
Bài 2.
Var i:integer;
begin
for i:=1 to 100 do
if i mod 2=0 then write(' Cac so chan tu 1 den 100 la: ',i,' ');
readln;
end.

Bình luận (4)
trần hoàng
Xem chi tiết
Nguyễn Lê Phước Thịnh
4 tháng 4 2022 lúc 21:53

#include <bits/stdc++.h>

using namespace std;

long long i,n,kt,j;

int main()

{

cin>>n;

for (i=2; i<=n; i++)

{

kt=0;

for (j=2; j*j<=i; j++)

if (i%j==0) kt=1;

if (kt==0) cout<<i<<" ";

}

return 0;

}

Bình luận (0)
Nguyễn Tân Lợi
Xem chi tiết
Nguyễn Lê Phước Thịnh
1 tháng 2 2023 lúc 8:19

uses crt;

var n,i:integer;

begin

clrscr;

readln(n);

for i:=0 to n do

if i mod 2=0 then write(i:5);

readln;

end.

Bình luận (0)
Tiểu cường
Xem chi tiết
Kiều Vũ Linh
24 tháng 2 2022 lúc 7:03

Var i,s:integer;

Begin

For i:=10 to 30 do

If i mod 2 = 0 then s:=s+i;

Write('Tong la ',s);

Readln;

End.

Bình luận (0)
Nguyen
Xem chi tiết
Nguyễn Lê Phước Thịnh
1 tháng 4 2021 lúc 22:38

1:

const fi='Dulieu.txt'

fo='ketqua.txt'

var f1,f2:text;

a:array[1..100]of integer;

i,n:integer;

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

n:=0;

while not eof(f1) do 

  begin

inc(n);

read(f1,a[n]);

end;

for i:=1 to n do 

  if (a[i]>0) and (a[i] mod 2=0) then write(f2,a[i]:4);

close(f1);

close(f2);

end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
1 tháng 4 2021 lúc 22:40

P/s: Cái này mình viết chương trình chính thôi nhé, còn hàm và thủ tục bạn tự viết nhé(chỉ cần lấy ý tưởng trong chương trình chính ra viết là được rồi)

2:

uses crt;

var a:array[1..100]of integer;

i,n,t:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do

 begin

write('A[',i,']='); readln(a[i]);

end;

t:=0;

for i:=1 to n do 

  if a[i]>=0 then t:=t+a[i];

writeln(t);

readln;

end.

Bình luận (1)
Pham Thuan
Xem chi tiết
Phía sau một cô gái
20 tháng 4 2023 lúc 21:31

program SoChanDenN;

var

     n, i: Integer;

begin

     Write('Nhap n: ');

     Readln(n);

     Write('Cac so chan tu 1 den ', n, ' la: ');

     for i := 1 to n do

     begin

          if i mod 2 = 0 then

               Write(i, ' ');

     end;

end.

Bình luận (0)
Hưng Quốc
Xem chi tiết
HT.Phong (9A5)
31 tháng 3 2023 lúc 16:51

1. Uses crt;

var n,i: integer;

begin clrscr;

readln(n);

for i:=1 to n do write(i:3);

readln;

end.

2. Uses crt;

var n,i: integer;

begin clrscr;

readln(n);

for i:=1 to n do if(i mod 2 = 0) then write(i:3);

readln;

end.

Bình luận (0)
láobốlaos
31 tháng 3 2023 lúc 16:54

1. Uses crt;

var n,i: integer;

begin clrscr;

readln(n);

for i:=1 to n do write(i:3);

readln;

end.

2. Uses crt;

var n,i: integer;

begin clrscr;

readln(n);

for i:=1 to n do if(i mod 2 = 0) then write(i:3);

readln;

end.

Bình luận (0)
Nguyễn Hoàng Duy
2 tháng 4 2023 lúc 16:31

1.

program InDaySoTuNhien;
var n, i: integer;
begin
   write('Nhap so nguyen duong n: ');
   readln(n);

   writeln('Day so tu 1 den ', n, ' la:');
   for i := 1 to n do
      write(i, ' ');
end.

2.

program InSoChan;
var
   n, i: integer;
begin
   write('Nhap so nguyen n: ');
   readln(n);

   writeln('Cac so nguyen chan trong khoang tu 1 den ', n, ' la:');
   for i := 1 to n do
   begin
      if i mod 2 = 0 then
         write(i, ' ');
   end;
end.

Bình luận (0)
Ngoc Anh Nguyen
Xem chi tiết
Trần Nam Khánh
16 tháng 5 2021 lúc 9:38

uses crt;
var a:array[1..90] of longint;
    n,i:integer;
begin
    clrscr;
    write('Nhap so luong phan tu (n<=90): '); readln(n);
    for i:=1 to n do
        begin
            write('Nhap phan tu thu ',i,': '); readln(a[i]);
        end;
    write('Cac so chan: ');
    for i:=1 to n do if a[i] mod 2=0 then write(a[i],' ');
    readln;
end.

Bình luận (0)
Nguyễn Lê Phước Thịnh
17 tháng 5 2021 lúc 9:51

uses crt;

var a:array[1..100]of integer;

i,n,dem:integer;

begin

clrscr;

write('Nhap n='); readln(n);

for i:=1 to n do 

 begin

write('A[',i,']='); readln(a[i]);

end;

dem:=0;

for i:=1 to n do 

if a[i] mod 2=0 then inc(dem);

writeln(dem);

readln;

end.

Bình luận (0)
Maiiii
Xem chi tiết
Nguyễn Lê Phước Thịnh
17 tháng 2 2023 lúc 7:41

#include <bits/stdc++.h>

using namespace std;

int main()

{

int n,A[100],dem,t;

cin>>n;

for (int i=1; i<=n; i++)

cin>>A[i];

dem=0; t=0;

for (int i=1; i<=n; i++)

if (A[i]%2==0) dem++;

else t+=A[i];

cout<<dem<<endl;

cout<<t;

return 0;

}

Bình luận (0)