Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <algorithm>
- using namespace std;
- ifstream fin ("listavecini.in");
- ofstream fout ("listavecini.out");
- int a[101][101],i,j,maxx,x,y,n;
- bool okx,oky;
- struct varf
- {
- int nrvec;
- int vec[100];
- }v[101];
- int main()
- {
- fin>>n;
- while(fin>>x)
- {
- fin>>y;
- okx=true;
- oky=true;
- for(i=1;i<=v[x].nrvec;i++)
- if(y==v[x].vec[i])
- okx=false;
- for(i=1;i<=v[y].nrvec;i++)
- if(x==v[y].vec[i])
- oky=false;
- if(okx==true)
- {
- v[x].nrvec++;
- v[x].vec[v[x].nrvec]=y;
- }
- if(oky==true)
- {
- v[y].nrvec++;
- v[y].vec[v[y].nrvec]=x;
- }
- }
- for(i=1;i<=n;i++)
- {
- fout << v[i].nrvec<<" ";
- sort(v[i].vec+1,v[i].vec+v[i].nrvec+1);
- for(j=1;j<=v[i].nrvec;j++)
- fout<<v[i].vec[j]<<" ";
- fout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement