Tin học Viết chương trình nhập vào dãy N số nguyên a)Tìm phần tử nhỏ nhất của dãy b)tính tổng các phần tử lẻ của dãy c)Sắp xếp dãy theo thứ tự giảm dần 16/07/2021 By Isabelle Viết chương trình nhập vào dãy N số nguyên a)Tìm phần tử nhỏ nhất của dãy b)tính tổng các phần tử lẻ của dãy c)Sắp xếp dãy theo thứ tự giảm dần
a) Uses Crt;Var a:array[1..1000] of integer;i,n,min:integer;BeginClrscr;Write(‘Nhap so ptu N = ‘); Readln(n);For i:= 1 to n doBeginWrite(‘Nhap a[‘,i,’]= ‘); Readln(a[i]);End;min:=a[1];For i:= 2 to n doBeginIf min>a[i] then min:=a[i];End;Writeln(‘So nho nhat trong day la: ‘,min);ReadlnEnd.b) Uses Crt;Var a:array[1..1000] of integer;i,n,tl:integer;BeginClrscr;Write(‘Nhap so ptu N = ‘); Readln(n);For i:= 1 to n doBeginWrite(‘Nhap a[‘,i,’]= ‘); Readln(a[i]);End;For i:= 1 to n do If a[i] mod 2 <> 0 then tl:=tl+a[i];Writeln(‘Tong cac so le trong day la: ‘);Write(tl:3);ReadlnEnd.c) Uses Crt;Var a:array[1..1000] of integer;i,n,j,tg:integer;BeginClrscr;Write(‘Nhap so ptu N= ‘); Readln(n);For i:=1 to n doBeginWrite(‘Nhap so thu a[‘,i,’]: ‘); Readln(a[i]);End;For i:=1 to n-1 doFor j:=i+1 to n doIf A[i]<A[j] thenBegintg:=A[i];A[i]:=A[j];A[j]:=tg;End;Writeln;Writeln(‘ Day so sau khi sap xep theo thu tu giam dan la: ‘);For i:= 1 to n do Write(a[i]:5);ReadlnEnd. Trả lời