Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int v[10][10],x,y,m,n,a[10],q,z,s[10],nod,nc;
- ifstream f("matrice.txt");
- void cit()
- {
- f>>n;
- while(f>>x>>y)
- {
- v[x][y]=1;
- v[y][x]=1;
- }
- }
- void af()
- {
- for(int i=1;i<=n;i++)
- {
- for(int j=1;j<=n;j++)
- {
- cout<<v[i][j]<<" ";
- }
- cout<<endl;
- }
- }
- void adan(int nod)
- {
- q++;
- cout<<nod;
- s[nod]=1;
- for(int i=1;i<=n;i++)
- {
- if(v[nod][i]==1 && s[i]==0)
- {
- s[i]=1;
- adan(i);
- }
- }
- }
- int abc()
- {
- for(int i=1;i<=n;i++)
- {
- z=0;
- for(int j=1;j<=n;j++)
- {
- z=z+v[i][j];
- }
- if(z%2==1)
- return 0;
- }
- return 1;
- }
- void conex()
- {
- int nc=0;
- for(int i=1;i<=n;i++)
- {
- if(s[i]==0)
- {
- nc++;
- cout<<"elem conexe: ";
- adan(i);
- }
- }}
- int main()
- {
- cit();
- af();
- conex();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement