Pagini recente » Cod sursa (job #2057975) | Cod sursa (job #2547632) | Cod sursa (job #3192984) | Cod sursa (job #328969) | Cod sursa (job #2089942)
#include <iostream>
#include <vector>
#include <fstream>
using namespace std;
vector <int> v(100);
ifstream fin("sortaret.in");
ofstream out("sortaret.out");
int n,m;
struct v{
int x;
int y;
}w[100];
void read()
{fin>>n;
fin>> m;
for(int i=0;i<m;i++)
fin>>w[i].x>>w[i].y;
}
void prelucreaza(int x)
{int ok=1;
for(int i=0;i<m;i++)
{
if(w[i].y==x and v[w[i].x]==0)
{prelucreaza(w[i].x);
ok=0;}
else
if(w[i].y==x and v[w[i].x]==1)
{
out<<x<<' ';
v[x]=1;
break;
ok=0;}
if(i==m-1 and ok==1)
{
out<<x<<' ';
v[x]=1;
}
}
}
int main()
{
read();
for(int i=1;i<=n;i++)
prelucreaza(i);
return 0;
}