Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include<fstream>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5. ifstream f("graf.txt");
  6. int a[100][100];
  7. int main()
  8. { int n,m,x,y,i,j,k,nr=0;
  9. f>>n>>m;
  10. while(f>>x>>y)
  11. a[x][y]=1;
  12. for(i=1;i<=n;i++)
  13. {
  14. for(j=1;j<=n;j++)
  15. cout<<a[i][j];
  16. cout<<endl;
  17. }
  18. for(k=1;k<=n;k++)
  19. { x=0;
  20. for(i=1;i<=k;i++)
  21. if(k%i==0)
  22. x++;
  23. if(x==2)
  24. for(j=1;j<=n;j++)
  25. a[j][k]=a[k][j]=0;
  26. }
  27. for(i=1;i<=n;i++)
  28. for(j=1;j<=n;j++)
  29. if(a[i][j]==1)
  30. nr++;
  31. cout<<nr;
  32. return 0;
  33. }
  34.  
  35. // de bagat in gra.txt
  36. 6
  37. 7
  38. 1 2
  39. 1 3
  40. 1 4
  41. 1 5
  42. 1 6
  43. 6 1
  44. 6 4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement