Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program chuyende1 ;
- uses crt ;
- var n,i : byte ;
- s,k,max, min1,min2 : integer ;
- a : array [0..100] of integer;
- begin
- clrscr ;
- write ('Nhap so tu nhien n: ') ; readln (n) ;
- for i := 1 to n do
- begin
- write ('Nhap phan tu thu ',i,': ') ;
- readln (a[i]) ;
- end;
- // Cau 1 //
- for i := 1 to n do write (a[i],' ') ;
- readln ;
- // Cau 2 //
- for i:=1 to n do
- if (a[i] > 0) then write (a[i],' ') ;
- readln ;
- // Cau 3 //
- for i:=1 to n do
- if (a[i] mod 2 <> 0) then write (a[i],' ') ;
- readln ;
- // Cau 4 //
- for i:=1 to n do
- if (i mod 2 = 0) then write (a[i],' ') ;
- readln ;
- // Cau 5//
- write ('Nhap k: '); readln (k) ;
- for i:=1 to n do
- if (k mod a[i] = 0) then write (a[i],' ') ;
- readln ;
- // Cau 6 //
- s := 0 ;
- for i := 1 to n do s:=s+a[i] ;
- write (s) ;
- readln ;
- // Cau 7 //
- s := 0 ;
- for i:=1 to n do
- if (a[i] mod 2 = 0) then s:=s+a[i] ;
- write (s) ;
- readln ;
- // Cau 8 //
- max := a[1] ;
- for i:=2 to n do
- if (max < a[i]) then max:=a[i] ;
- write (max) ;
- readln ;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement