Advertisement
Guest User

Untitled

a guest
Apr 26th, 2018
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n,m,i,j,v[100][100],x,y,p,ext,inter,gr;
  8. cout<<"Dati numarul de noduri : ";cin>>n;cout<<endl;
  9. cout<<"Dati numarul de muchii : ";cin>>m;cout<<endl;
  10. for(i=1;i<=m;i++)
  11. {
  12. cout<<"Elementele arcului numarul "<<i<<" sunt : ";cin>>x>>y;
  13. cout<<endl;
  14. v[x][y]=1;
  15. }
  16. cout<<endl;
  17.  
  18. cout<<"Dati nodul al carui grade vreti sa aflati: ";cin>>p;cout<<endl;
  19.  
  20. for(i=1;i<=n;i++)
  21. {
  22. for(j=1;j<=n;j++)
  23. cout<<v[i][j]<<" ";
  24. cout<<endl;
  25. }
  26. cout<<endl;
  27. inter=0;
  28. for(i=1;i<=n;i++)
  29. {
  30. inter=inter+v[i][p];
  31. }
  32. ext=0;
  33. for(j=1;j<=n;j++)
  34. {
  35. ext=ext+v[p][j];
  36. }
  37. for(i=1;i<=n;i++)
  38. { gr=0;
  39. for(j=1;j<=n;j++)
  40. {
  41. gr=gr+v[i][j];
  42. }
  43. if(gr==0)
  44. cout<<"Nodul "<<i<<" este izolat."<<endl;
  45.  
  46. }
  47.  
  48.  
  49. cout<<"Gradul extern al nodului "<<p<<" este : "<<ext<<endl;
  50. cout<<"Gradul interior al nodului "<<p<<" este : "<<inter<<endl;
  51.  
  52.  
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement