Advertisement
alexon5519

32-programare

Feb 28th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3.  
  4. int perfect(int a){
  5. int i,s=0;
  6. for(i=1;i<=a/2;i++)
  7. if(a % i == 0)
  8. s=s+i;
  9. if( s == a )
  10. return 1;
  11. return 0;
  12. }
  13.  
  14.  
  15.  
  16. using namespace std;
  17.  
  18. int A[100][100];
  19. int main(){
  20. ifstream f1("atestat.in");
  21. ofstream f2("atestat.out");
  22. int n,p,v,l,c,s=0,i,j;
  23. f1>>n>>p;
  24. for(i=1;i<=p;i++){
  25. f1>>v>>l>>c;
  26. A[l][c]=v;
  27. s=s+v;
  28. }
  29. for(i=1;i<=n;i++){
  30. for(j=1;j<=n;j++)
  31. f2<<A[i][j]<<" ";
  32. f2<<endl;
  33. }
  34. if(perfect(s) == 1)
  35. f2<<"DA";
  36. else
  37. f2<<"NU";
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement