Guest User

Untitled

a guest
Sep 16th, 2019
113
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <fstream>
  2.  
  3. using namespace std;
  4.  
  5. void citire(int a[10][10], int &n){
  6. int i,j;
  7. ifstream f("date.in");
  8. f >> n;
  9. for(i = 1 ; i <= n ; i++)
  10. for(j = 1 ; j <= n ; j++)
  11. f >> a[i][j];
  12. f.close();
  13. }
  14.  
  15. ofstream g("date.out");
  16. void afisare(int a[10][10], int n){
  17. int i,j;
  18. for(i = 1 ; i <= n ; i++){
  19. for(j = 1 ; j <= n ; j++)
  20. g << a[i][j] << " ";
  21. g << "\n";
  22. }
  23. }
  24.  
  25. int grad(int a[10][10], int x, int n){
  26. int j,sum = 0;
  27. for(j = 1 ; j <= n ; j++)
  28. if(a[x][j])
  29. sum++;
  30. return sum;
  31. }
  32.  
  33. int gradmax(int a[10][10],int node, int n){
  34. int Max = grad(a,1,n),nodemax = 1,i;
  35. for(i = 2 ; i <= n ; i++)
  36. if(grad(a,i,n) > Max){
  37. Max = grad(a,i,n);
  38. nodemax = i;
  39. }
  40. return nodemax;
  41. }
  42.  
  43. int main()
  44. {
  45. int a[10][10],n;
  46. citire(a,n);
  47. afisare(a,n);
  48. g << gradmax(a,4,n);
  49. g.close();
  50. return 0;
  51. }
RAW Paste Data