Những câu hỏi liên quan
DinoDrang
Xem chi tiết
Nguyễn Lê Phước Thịnh
21 tháng 2 2023 lúc 15:38

uses crt;

var n,i,t:integer;

begin

clrscr;

readln(n);

t:=0;

for i:=1 to n do

if i mod 2=0 then t:=t+i;

write(t);

readln;

end.

Bình luận (0)
Phan Thị Ka
Xem chi tiết
Minh Lệ
19 tháng 3 2023 lúc 22:40

Câu 1:

Program HOC24;

var i,p: integer;

t: longint;

begin

write('Nhap P: '); readln(p);

t:=0;

for i:=1 to p do if i mod 2<>0 then t:=t+i;

write('Tong cac so le la: ',t);

readln

end.

Bình luận (0)
Minh Lệ
19 tháng 3 2023 lúc 22:41

Câu 2:

Program HOC24;

var i,n: integer;

t: longint;

begin

write('Nhap N: '); readln(n);

t:=0;

for i:=1 to n do if i mod 2=0 then t:=t+i;

write('Tong cac so chan la: ',t);

readln

end.

Bình luận (0)
Minh Lệ
19 tháng 3 2023 lúc 22:42

Câu 3:

Program HOC24;

var i,t,n: integer;

begin

write('Nhap N: '); readln(n);

t:=0;

for i:=1 to n do if n mod i=0 then t:=t+i;

write('Tong cac uoc cua ',n,' la: ',t);

readln

end.

Bình luận (0)
foxbi
Xem chi tiết
HT.Phong (9A5)
18 tháng 3 2023 lúc 7:00

Uses crt;

var n,i,x,u: integer;

begin clrscr;

readln(n);

for i:=1 to n do begin

readln(x);

u:=u+x;

end;

writeln(u);

readln;

end.

Bình luận (0)
Trần Đức Hải Phong
25 tháng 12 2023 lúc 16:54

program TongCacSoNguyen;

var
  N, i, soNguyen, tong: integer;

begin
  // Nhập số lượng N
  write('Nhap so luong N: ');
  readln(N);

  // Khởi tạo tổng
  tong := 0;

  // Nhập và tính tổng các số nguyên
  for i := 1 to N do
  begin
    write('Nhap so nguyen thu ', i, ': ');
    readln(soNguyen);
    tong := tong + soNguyen;
  end;

  // In ra màn hình tổng
  writeln('Tong cua cac so nguyen la: ', tong);

  readln;
end.

Bình luận (0)
dinhnguyentuhuy
Xem chi tiết
Nguyễn Lê Phước Thịnh
13 tháng 12 2020 lúc 17:15

uses crt;

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

i,n,t,kt,j:integer;

begin

clrscr;

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

for i:=1 to n do

begin

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

end;

writeln('Cac so vua nhap la: ');

for i:=1 to n do 

  write(a[i]:4);

writeln;

t:=0;

for i:=1 to n do 

  t:=t+a[i];

writeln('Tong cua day so la: ',t);

kt:=0;

for j:=2 to trunc(sqrt(t)) do 

  if t mod j=0 then 

    begin

kt:=1;

break;

end;

if kt=0 then writeln(t,' la so nguyen to')

else writeln(t,' khong la so nguyen to');

readln;

end.

Bình luận (1)
dinhnguyentuhuy
Xem chi tiết
Nguyễn Lê Phước Thịnh
13 tháng 12 2020 lúc 22:29

uses crt;

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

i,n,t,kt:integer;

begin

clrscr;

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

for i:=1 to n do

begin

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

end;

writeln('Cac so ban vua nhap la: ');

for i:=1 to n do 

write(a[i]:4);

writeln;

t:=0;

for i:=1 to n do

t:=t+a[i];

writeln('Tong cac so vua nhap la: ',t);

if t>=2 then 

begin

kt:=0;

for i:=2 to trunc(sqrt(t)) do 

  if t mod i=0 then 

begin

kt:=1;

break;

end;

 if kt=0 then writeln(t,' la so nguyen to')

else writeln(t,' khong la so nguyen to');

end

else writeln(t,' khong la so nguyen to');

readln;

end.

Bình luận (0)
Trần Hà Thư
Xem chi tiết
Nguyễn Lê Phước Thịnh
7 tháng 5 2021 lúc 22:07

uses crt;

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

i,n:integer;

begin

clrscr;

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

for i:=1 to n do 

  begin

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

end;

for i:=1 to n do 

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

readln;

end.

Bình luận (0)
Lê Thị Thu Phương
7 tháng 6 2021 lúc 21:02

uses crt;
var a:array[1..1000000] of longint;
      n,i:longint;
begin
      clrscr;
      write('Nhap so luong phan tu: '); 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)
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)
Chouu11
Xem chi tiết
Kiều Vũ Linh
16 tháng 5 2023 lúc 7:39

Var n,sc,sl,i:longint;

Begin

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

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

For i:=1 to n do

Write(i:8);

Writeln;

For i:=1 to n do

Begin

If i mod 2 = 0 then sc:=sc+i

Else sl:=sl+i;

End;

Writeln('Tong cac so chan la ',sc);

Write('Tong cac so le la ',sl);

Readln

End.

Bình luận (0)
Nguyễn Thanh Anh
Xem chi tiết