Advertisement
tonstons

chuyende1_tu_1_den_8

Apr 28th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.18 KB | None | 0 0
  1. program chuyende1 ;
  2. uses crt ;
  3. var n,i : byte ;
  4.     s,k,max, min1,min2 : integer ;
  5.     a : array [0..100] of integer;
  6. begin
  7.     clrscr ;
  8.     write ('Nhap so tu nhien n: ') ; readln (n) ;
  9.     for i := 1 to n do
  10.     begin
  11.         write ('Nhap phan tu thu ',i,': ') ;
  12.         readln (a[i]) ;
  13.     end;
  14.     // Cau 1 //
  15.     for i := 1 to n do write (a[i],' ') ;
  16.     readln ;
  17.     // Cau 2 //
  18.     for i:=1 to n do
  19.         if (a[i] > 0) then write (a[i],' ') ;
  20.     readln ;
  21.     // Cau 3 //
  22.     for i:=1 to n do
  23.         if (a[i] mod 2 <> 0) then write (a[i],' ') ;
  24.     readln ;
  25.     // Cau 4 //
  26.     for i:=1 to n do
  27.         if (i mod 2 = 0) then write (a[i],' ') ;
  28.     readln ;
  29.     // Cau 5//
  30.     write ('Nhap k: '); readln (k) ;
  31.     for i:=1 to n do
  32.         if (k mod a[i] = 0) then write (a[i],' ') ;
  33.     readln ;
  34.     // Cau 6 //
  35.     s     := 0 ;
  36.     for i := 1 to n do s:=s+a[i] ;
  37.     write (s) ;
  38.     readln ;
  39.     // Cau 7 //
  40.     s := 0 ;
  41.     for i:=1 to n do
  42.         if (a[i] mod 2 = 0) then s:=s+a[i] ;
  43.     write (s) ;
  44.     readln ;
  45.     // Cau 8 //
  46.     max := a[1] ;
  47.     for i:=2 to n do
  48.         if (max < a[i]) then max:=a[i] ;
  49.     write (max) ;
  50.     readln ;
  51. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement