K
Khách

Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.

30 tháng 12 2022

uses crt;

var n,i:integer;

begin

clrscr;

readln(n);

for i:=1 to n do

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

readln;

end.

Ủa bạn ngay chỗ var n i: integer có thể thay thế bằng longint ko

22 tháng 4 2023

program TongSoChanTrongDay;

var

      n, i, tong: integer;

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

begin

      tong := 0;

      write('Nhap so phan tu cua day: ');

      readln(n);

      for i := 1 to n do

      begin

            write('Nhap phan tu thu ', i, ': ');

            readln(a[i]);

            if a[i] mod 2 = 0 then

                  tong := tong + a[i];

      end;

      writeln('Tong cac phan tu chan trong day la: ', tong);

      readln;

end.

3 tháng 5

fgfgfgfgfgfggfgfgfggggfgf

9 tháng 4 2021

Uses crt;
Var a,b,n:integer; {hoặc real,longint {tùy vào đơn vị của các số có nhỏ hay lớn}}
Begin
Writeln('Nhap so n la:'); Readln(n);
a:=0; b:=0;
While a<=n do
 Begin
   b:=b+a;
   a:=a+1; {chỉ áp dụng khi tính tổng liên tiếp từ 1->n, không áp dụng tính tổng các số chẵn}
 end;
Writeln('Vay tong cac so tu 1 -> ',n,' la:',b);
Readln
End.
*Nếu bạn muốn giải theo cách for..do hay tính tổng các số chẵn hay gì gì đó liên quan đến Tin học thì bảo mình nhé* Good luck for you :D :D 

uses crt;

var n,i,t:integer;

begin

clrscr;

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

t:=0;

for i:=1 to n do 

  t:=t+i;

writeln(t);

readln;

end.

9 tháng 5 2021

program mang;
uses crt;
var n,i,chan, le,max,min: Integer;
a:array[1..100] of integer;
begin
write('nhap so phan tu ');read(n);
for i:=1 to n do
begin
write('nhap so thu ',i); readln(a[i]);
end;
max:=a[1]; min:=a[1]; chan:=0;le:=0;
for i:=1to n do
begin
if a[i] > max then max:=a[i];
if a[i] < min then min:=a[i];
if a[i] mod 2 = 0 then chan:=chan+1
else le:=le+1;
end;
writeln('max la: ',max);
writeln('min la: ',min);
writeln('so phan tu chan: ',chan);
writeln('so phan tu le: ',le);
readln
end.

7 tháng 5 2023

program Le_Nho_Hon_Hoac_Bang_n;

uses crt;

var

       n, i: integer;

begin

       clrscr;

       write('Nhap vao mot so nguyen duong n: ');

       readln(n);

       while n <= 0 do

       begin

              writeln('So ban nhap khong hop le. Xin vui long nhap lai: ');

              readln(n);

       end;

       clrscr;

       writeln('Cac so le nho hon hoac bang ', n, ' la:');

       i := 1;

       while i <= n do

       begin

              if i mod 2 <> 0 then

                     writeln(i);

              i := i + 1;

       end;

       readln;

end.

#include <bits/stdc++.h>

using namespace std;

long long i,n;

int main()

{

cin>>n;

for (i=1; i<=n; i++) if (i%2==0) cout<<i<<" ";

return 0;

}

22 tháng 1 2022

Var n,i,so:integer;

Begin

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

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

For i:=1 to n do

If i mod 2 = 0 then write(i,'   ');

Readln;

End.

#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;

}

22 tháng 4 2023

Câu 1: Viết chương trình nhập vào N số nguyên từ bàn phím tính tích các số chia hết cho 3?

program TichSoChiaHetCho3;

var

      n, i, tich: integer;

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

begin

      tich := 1;

      write('Nhap so phan tu cua day: ');

      readln(n);

      for i := 1 to n do

      begin

            write('Nhap phan tu thu ', i, ': ');

            readln(a[i]);

            if a[i] mod 3 = 0 then

            begin

                  tich := tich * a[i];

            end;

      end;

      writeln('Tich cac phan tu chia het cho 3 la: ', tich);

      readln;

end.
Câu 2: Viết chương trình nhập vào N số nguyên từ bàn phím đếm xem có bao nhiêu số chẵn trong các số vừa nhập?

program DemSoChanTrongDay;

var

      n, i, tich: integer;

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

begin

      dem := 0;

      write('Nhap so phan tu cua day: ');

      readln(n);

      for i := 1 to n do

      begin

            write('Nhap phan tu thu ', i, ': ');

            readln(a[i]);

            if a[i] mod 2 = 0 then

            begin

                  dem := dem + 1;

            end;

      end;

      writeln('So phan tu chan trong day la: ', dem);

      readln;

end.
Câu 3: Viết chương trình nhập vào N số nguyên từ bàn phím hiển thị các số có giá trị nhỏ hơn hoặc bằng 20?

program HienThiSoNhoHon20;

var

      n, i: integer;

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

begin

      write('Nhap so phan tu cua day: ');

      readln(n);

      for i := 1 to n do

      begin

            write('Nhap phan tu thu ', i, ': ');

            readln(a[i]);

            if a[i] <= 20 then

            begin

                  writeln(a[i]);

            end;

      end;

      readln;

end.