Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<fstream>
- #include <iostream>
- using namespace std;
- ifstream f("graf.txt");
- int a[100][100];
- int main()
- { int n,m,x,y,i,j,k,nr=0;
- f>>n>>m;
- while(f>>x>>y)
- a[x][y]=1;
- for(i=1;i<=n;i++)
- {
- for(j=1;j<=n;j++)
- cout<<a[i][j];
- cout<<endl;
- }
- for(k=1;k<=n;k++)
- { x=0;
- for(i=1;i<=k;i++)
- if(k%i==0)
- x++;
- if(x==2)
- for(j=1;j<=n;j++)
- a[j][k]=a[k][j]=0;
- }
- for(i=1;i<=n;i++)
- for(j=1;j<=n;j++)
- if(a[i][j]==1)
- nr++;
- cout<<nr;
- return 0;
- }
- // de bagat in gra.txt
- 6
- 7
- 1 2
- 1 3
- 1 4
- 1 5
- 1 6
- 6 1
- 6 4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement