Untitled
unknown
plain_text
3 years ago
711 B
4
Indexable
Never
#include<stdio.h> #include<math.h> int main(){ int i,n; int a[100]; do{ printf("Nhap so phan tu n = "); scanf("%d", &n); }while(n<0 || n>100); for(i=0; i<n; i++){ printf("\nNhap a[%d]:",i); scanf("%d", &a[i]); } // a,SO CHINH PHUONG int dem1=0; for (i=0; i<n; i++){ if(sqrt(a[i]) == (int)sqrt(a[i])) dem1++; } printf("\nCo %d so chinh phuong ", dem1); printf("\nSo chinh phuong la:"); for(i=0;i<=n;i++){ int t=(int)sqrt(a[i]); if( pow(t,2)==a[i]){ printf("%d ", a[i]); } } //b,SO HOAN HAO int tong; for (i=0; i<n; i++){ if(n % i == 0) tong = tong + i; } if (tong == n){ printf("So hoan hao: %d ", n); } return 0; }