Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. int a[101][101],n,m=0;
  5. void citire()
  6. {
  7. int x,y;
  8. ifstream f("listavecini.in");
  9. f>>n;
  10. while(f>>x>>y)
  11. {
  12. a[x][y]=a[y][x]=1;
  13. }
  14. f.close();
  15. }
  16. void liste()
  17. {
  18. int i, j;
  19. ofstream g("listavecini.out");
  20. for(i=1;i<=n;i++)
  21. {
  22. for(j=1;j<=n;j++)
  23. if(a[i][j]==1)
  24. m++;
  25. g<<m<<" ";
  26. for(j=1;j<=n;j++)
  27. if(a[i][j]==1)
  28. g<<j<<" ";
  29. g<<endl;
  30. m=0;
  31. }
  32. g.close();
  33. }
  34. int main()
  35. {
  36. citire();
  37. liste();
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement