[r]
(1)# include<conio.h> #include< iostream.h> #include<iomanip.h> 'dung cho lenh setw Void nhapmang (int a[], int n) { for (int i=0; i<n; i++) { Cout<<"a["<<i+1<<"]="; Cin>>a[i]; } } Void inmang(int a[], int n) { for (int i=0; i<n; i++) Cout<<setw(4)<<a[i]; Cout<<endl; } Void sapxep(int a[], int n) { for (int i=0; i<n-1;i++) For (int j= i+1; j<n; j++) If ( a[i]> a[j] ) { int tg = a[i]; A[i] = a[j]; A[j] = tg; } Int timmax (int a[], int n) { int max = a[0]; For (int i = 1;i< n; i++) If ( a[i]>max) Max= a[i]; Return max; } Int timmin (int a[], int n) { int = a[0]; For (int i = 1;i< n; i++) If ( a[i]< min) Min= a[i]; Return min; } Void main() { clrscr(); Int n, a[100]; Cout<<"nhap cac gia tri cho mang\n"; Nhapmang(a,n); Cout<<"mang vua nhap la\n"; Inmang(a,n); Max= timmax (a,n); Cout<<"max ="<<timmax(a,n)<<endl; Min= timmin(a,n); Cout<<"min="<< timmin(a,n); Cout<<"mang sau sap xep la\n"; (2) Sapxep (a,n); Getch(); } (3)