Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. ifstream f ("atestat.in");
  5. ofstream g ("atestat.out");
  6. int n,M[11][11];
  7.  
  8. void citire()
  9. {
  10. f>>n;
  11. int x,y;
  12. while (f>>x>>y)
  13. {
  14.  
  15. M[x][y]=M[y][x]=1;
  16.  
  17. }
  18. }
  19. void a()
  20. {
  21. for(int i=1;i<=n;i++)
  22. {
  23. for (int j=1;j<=n;j++)
  24. cout<<M[i][j]<<" ";
  25. cout<<endl;
  26. }
  27. }
  28. void b()
  29. {
  30. int v,c=0;
  31. cin>>v;
  32. for(int i=1;i<=n;i++)
  33. {
  34. if(M[v][i])
  35. c++;
  36. }
  37. cout<<c;
  38. }
  39. void c()
  40. {
  41. for(int i=1;i<=n;i++)
  42. {
  43. for(int j=1;j<=n;j++)
  44. {
  45.  
  46. if(M[i][j]==0 && i!=j)
  47. M[i][j]=1;
  48. g<<M[i][j]<<" ";
  49.  
  50. }g<<endl;
  51. }
  52.  
  53. }
  54. int main()
  55. {citire();
  56. a();
  57. b();
  58. c();
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement