#include<iostream> using namespace std; int shh(int x) { long i,s=0; for (i=1;i<x;i++) { if(x%i==0) s=s+i; } if(s==x) return 1; else return 0; } void main() { int *p,i,j,n,m,imax,imin,tich=1,t=0; cout<<"nhap so phan tu"; cout<<"nhap so ptu ="; cin>>n; p=new int[n]; for(i=0;i<n;i++) { cout<<"nhap gia tri ptu thu "<<(i+1)<<"="; cin>>*(p+i); } for(i=0;i<n;i++) cout<<*(p+i)<<"\t"; cout<<endl; //chen phan tu vao cout<<"nhap ptu can them vao day"<<endl; cin>>m; cout<<"\nphan tu "<<m<<" da duoc them vao day: "; n++; p[n-1]=m; //sap xep for(i=0;i<n;i++) for(j=i+1;j<n;j++) if(*(p+i)>*(p+j)) { int tg=*(p+i); *(p+i)=*(p+j); *(p+j)=tg; } cout<<"day da dc sap xep"<<endl; for(i=0;i<n;i++) cout<<*(p+i)<<"\t"; cout<<endl; //tim max, min for(imax=0,imin=0,i=0;i<n;i++) { if(p>p[imax])imax=i; if(p<p[imin])imin=i; } cout<<"So lon nhat la :"<<p[imax]<<endl; cout<<"So nho nhat la :"<<p[imin]<<endl; //tich for(i=0;i<n;i++) tich=tich*p; cout<<"tich mang la "<<tich; cout<<endl; //tong for(i=0;i<n;i++) t=t+p; cout<<"tich mang la "<<t; cout<<endl; //goi ham sohh for(i=0;i<n;i++) { if(shh(*(p+i))) cout<<*(p+i)<<" la so hoan hao"<<endl; } }