Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int n,m,a[101][101];
- ifstream f("fmmviata.in");
- void citire()
- {
- int i,j;
- f>>n;
- while (f>>i>>j) {a[i][j]=a[j][i]=1;
- m++;}
- }
- int gr(int nod)
- {
- int x,s=0;
- for(x=1;x<=n;x++)
- s=s+a[nod][x];
- return s;
- }
- int main()
- {
- citire();
- int i,j,p=0,ok=0;
- cout<<"nr muchii: "<<m;
- cout<<endl<<"grade izolate: ";
- for(i=1;i<=n;i++)
- if(gr(i)==0)p++;
- cout<<p;
- cout<<endl<<"noduri grad par: ";
- for(i=1;i<=n;i++)
- if(gr(i)%2==0) cout<<i<<" ";
- for(i=1;i<=n;i++)
- if(gr(i)!=n-1)ok=1;
- if(ok==0)cout<<endl<<"graful este complet.";
- else cout<<endl<<"graful nu este complet.";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement