UberKill11

Graf

Dec 15th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. int a[101][101],x[101],n;
  5. void citire(void)
  6. {
  7. int i,j;
  8. ifstream f("matrice.in");
  9. f>>n;
  10. for(i=1;i<=n;i++)
  11. for(j=1;j<=n;j++)
  12. f>>a[i][j];
  13. f.close()}
  14.  
  15. void grade(void)
  16. {int i,j;
  17.  
  18. for(i=1;i<=n;i++)
  19. {
  20. x[i]=0;
  21. for(j=1;j<=n;j++)
  22. x[i]=x[i]+a[i][j];
  23. }
  24. }
  25.  
  26. void noduri(void)
  27. {
  28. int i;
  29. cout<<"{";
  30. for(i=1;i<=n;i++)
  31. cout<<i<<",";
  32. cout<<n<<"}";
  33.  
  34. }
  35.  
  36.  
  37. void muchii(void)
  38. {
  39. int i,j; cout<<"{";
  40. for(i=1;i<n;i++)
  41. for(j=i+1;j<=n;j++)
  42. if(a[i][j]==1)
  43. cout<<"("<<i<<","<<j<<")";
  44. cout<<"}"<<endl;}
  45.  
  46.  
  47. void afisaregrade(void)
  48. {
  49. int i;
  50. for(i=1;i<=n;i++)
  51. cout<<x[i]<<" ";
  52. cout<<endl;
  53. }
  54.  
  55.  
  56. void varfuriizolate(void)
  57. {
  58. int i,ok=0;
  59. for(i=1;i<=n;i++)
  60. if( x[i]==0)
  61. cout<<i<<" ";
  62. ok=1;}
  63. if(ok==0)
  64. cout<<"Nu exista varfuri izolate";
  65. cout<<endl;
  66.  
  67.  
  68. void varfuriterminale(void)
  69. {
  70. int i,ok=0;
  71. for(i=1;i<=n;i++)
  72. if(x[i]==1)
  73. {
  74.  
  75. cout<<i<<" "; ok=1;}
  76. if(ok==0)
  77. cout<<"Nu exista varfuri terminale";
  78. cout<<endl;}
  79.  
  80.  
  81. void maxim(void)
  82. {
  83. int i,max1=0;
  84. for(i=1;i<=n;i++)
  85. if(max1<x[i])
  86. max1=x[i];
  87. for(i=1;i<=n;i++)
  88. if(max1=x[i])
  89. cout<<i<<" ";
  90. cout<<endl;
  91. }
  92.  
  93.  
  94.  
  95. int main()
  96. {
  97. int m;
  98. citire();
  99. grade();
  100. do
  101. {
  102. cout<<"1.Afisarea multime varfuri"<<endl;
  103. cout<<"2.Afisarea multimii muchiilor"<<endl;
  104. o
  105. o
  106. o
  107. cout<<"7.Iesire"<<endl;
  108. cin>>m;
  109. if(m==1)
  110. noduri();
  111. if(m==2)
  112. muchii();
  113. if(m==3)
  114. afisaregrade();
  115. if(m==4)
  116. afisare();
  117. if(m==5)
  118. varfuriterminale();
  119. if(m==6)
  120. maxim();
  121. while(m!=7);
  122.  
  123. }
  124. return 0;
  125. }
Advertisement
Add Comment
Please, Sign In to add comment