Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- int perfect(int a){
- int i,s=0;
- for(i=1;i<=a/2;i++)
- if(a % i == 0)
- s=s+i;
- if( s == a )
- return 1;
- return 0;
- }
- using namespace std;
- int A[100][100];
- int main(){
- ifstream f1("atestat.in");
- ofstream f2("atestat.out");
- int n,p,v,l,c,s=0,i,j;
- f1>>n>>p;
- for(i=1;i<=p;i++){
- f1>>v>>l>>c;
- A[l][c]=v;
- s=s+v;
- }
- for(i=1;i<=n;i++){
- for(j=1;j<=n;j++)
- f2<<A[i][j]<<" ";
- f2<<endl;
- }
- if(perfect(s) == 1)
- f2<<"DA";
- else
- f2<<"NU";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement