Transformati un graf orientat complet in graf turneu. Graful complet se da cu n varfuri si m arce prin lista arcelor. Graful turneu se va afisa ca matrice de adiacenta.
Exemplu:
date.in
3 5
1 2
1 3
2 1
2 3
3 1
date.out:
0 1 1
0 0 1
0 0 0
#include <fstream>
using namespace std;
ifstream fin("date.in");
ofstream fout("date.out");
int A[100][100],n,m;
void citire()
{
int i,j,p;
fin>>n>>m;
for(p=1;p<=m;p++)
{
fin>>i>>j;
A[i][j]=1;
}
}
int main()
{
int i,j;
citire();
for(i=1;i<=n;i++)
for(j=i+1;j<=n;j++)
if(A[j][i]+A[i][j]==2) A[j][i]=0;
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
fout<<A[i][j]<<" ";
fout<<endl;
}
fin.close();
fout.close();
return 0;
}