Advertisement
NoHatred0

Atestat28

Feb 4th, 2013
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. #include <iostream.h>
  2. #include <fstream.h>
  3.  
  4. using namespace std;
  5.  
  6. ifstream f("atestat.in");
  7. ofstream g("atestat.out");
  8.  
  9. int n,a[100][100],v;
  10.  
  11. void citire()
  12. {
  13. int x,y;
  14. f>>n;
  15. while(!f.eof())
  16. {
  17. f>>x;f>>y;
  18. a[x][y]=1;
  19. a[y][x]=1;
  20. }
  21.  
  22. }
  23. void afisare()
  24. {
  25. int i,j;
  26. for(i=1;i<=n;i++)
  27. {
  28. for(j=1;j<=n;j++)
  29. cout<<a[i][j]<<" ";
  30. cout<<endl;
  31. }
  32. }
  33. int grad(int x)
  34. {
  35. int i,s=0;
  36. for(i=1;i<=n;i++)
  37. s=s+a[x][i];
  38. return s;
  39. }
  40. void transformare()
  41. {
  42. int i;
  43. for(i=1;i<=n;i++)
  44. a[v][i]=0;
  45. for(i=1;i<=n;i++)
  46. a[i][v]=0;
  47. }
  48. void afisare2()
  49. {
  50. int i,j;
  51. for(i=1;i<=n;i++)
  52. {
  53. for(j=1;j<=n;j++)
  54. g<<a[i][j]<<" ";
  55. g<<endl;
  56. }
  57. }
  58. int main()
  59. {
  60. int i;
  61. citire();
  62. afisare();
  63. int max=grad(1);
  64. for(i=1;i<=n;i++)
  65. if(grad(i)>=max)
  66. max=grad(i);
  67. for(i=1;i<=n;i++)
  68. if(grad(i)==max)
  69. cout<<i<<" ";
  70. cout<<endl;
  71. cout<<"v=";cin>>v;
  72. transformare();
  73. afisare2();
  74. return 0;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement