Advertisement
Aniebunny

Nu stiu ce

Oct 13th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. int v[10][10],x,y,m,n,a[10],q,z,s[10],nod,nc;
  7.  
  8. ifstream f("matrice.txt");
  9.  
  10.  
  11. void cit()
  12. {
  13. f>>n;
  14. while(f>>x>>y)
  15. {
  16. v[x][y]=1;
  17. v[y][x]=1;
  18. }
  19. }
  20.  
  21. void af()
  22. {
  23. for(int i=1;i<=n;i++)
  24. {
  25. for(int j=1;j<=n;j++)
  26. {
  27. cout<<v[i][j]<<" ";
  28. }
  29. cout<<endl;
  30. }
  31. }
  32.  
  33. void adan(int nod)
  34. {
  35. q++;
  36. cout<<nod;
  37. s[nod]=1;
  38. for(int i=1;i<=n;i++)
  39. {
  40.  
  41. if(v[nod][i]==1 && s[i]==0)
  42. {
  43. s[i]=1;
  44. adan(i);
  45. }
  46. }
  47. }
  48.  
  49. int abc()
  50. {
  51. for(int i=1;i<=n;i++)
  52. {
  53. z=0;
  54. for(int j=1;j<=n;j++)
  55. {
  56. z=z+v[i][j];
  57. }
  58. if(z%2==1)
  59. return 0;
  60. }
  61. return 1;
  62. }
  63.  
  64. void conex()
  65. {
  66. int nc=0;
  67. for(int i=1;i<=n;i++)
  68. {
  69. if(s[i]==0)
  70. {
  71. nc++;
  72. cout<<"elem conexe: ";
  73. adan(i);
  74. }
  75. }}
  76.  
  77. int main()
  78. {
  79. cit();
  80. af();
  81.  
  82.  
  83.  
  84. conex();
  85. return 0;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement