DUYSONGLOI

huhu

Apr 16th, 2019
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.81 KB | None | 0 0
  1. program test;
  2. var i, n, soCacSoLe : integer; {i: bien dem ; n: so nguyen nhap tu ban phim ; soCacSoLe : so cac so le trong day so}
  3.     tong : longint; {tong : tong cua cac so le trong day so}
  4.     A : array [1..100] of integer;
  5. begin
  6.     {Nhap do dai cho day so}
  7.     write('Do dai cua day so: ');
  8.     read(n);
  9.  
  10.     {Nhap gia tri cho day so}
  11.     writeln('Nhap gia tri cho day so >');
  12.     for i:=1 to n do
  13.         begin
  14.             write('So thu [', i, '] : ');
  15.             read(A[i]);
  16.         end;
  17.  
  18.     {In ra man hinh day so do}
  19.     writeln('In ra man hinh day so do >');
  20.     for i:=1 to n do writeln(A[i]);
  21.  
  22.     {Tong cac so le trong day so}
  23.     tong:=0;
  24.     soCacSoLe:=0;
  25.     for i:=1 to n do
  26.         begin
  27.             if (A[i] mod 2 <> 0) then
  28.                 begin
  29.                     s:=s + A[i];
  30.                     soCacSoLe:=soCacSoLe + 1;
  31.                 end;
  32.         end;
  33.     writeln('Tong cac se le: ' s/soCacSoLe);
  34.     readln;
  35. end.
Advertisement
Add Comment
Please, Sign In to add comment