Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. std::ofstream out("date.out");
  7.  
  8. void citire(int a[10][10],int &n)
  9. {
  10. std::ifstream in("date.in");
  11. in>>n;
  12. int i,j;
  13. for(i=1;i<=n;i++)
  14. for(j=1;j<=n;j++)
  15. in>>a[i][j];
  16.  
  17. in.close();
  18. }
  19.  
  20. void afisare(int a[10][10],int n)
  21. {
  22. int i,j;
  23. for(i=1;i<=n;i++){
  24. for(j=1;j<=n;j++)
  25. out<<a[i][j];
  26. out<<'\n';
  27. }
  28. }
  29. int grad(int a[10][10],int n,int j)
  30. {
  31. int i,x=0;
  32. for(i=1;i<=n;i++)
  33. x+=a[i][j];
  34. return x;
  35. }
  36. int main()
  37. {
  38. int a[10][10],n,d[10],maxim=0;
  39. citire(a,n);
  40. for(int j=1;j<=n;j++)
  41. {
  42. d[j]=grad(a,n,j);
  43. maxim=max(maxim,d[j]);
  44. }
  45. cout<<"Gradul maxim: "<<maxim<<"\nPozitiile pe care se gaseste gradul maxim: ";
  46. for(int j=1;j<=n;j++)
  47. {
  48. if(maxim==d[j])
  49. cout<<j<<" ";
  50. }
  51. afisare(a,n);
  52. out.close();
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement