Cod sursa(job #972508)

Utilizator costin7856Antonesi Florean Costin costin7856 Data 11 iulie 2013 21:29:30
Problema Order Scor 65
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.52 kb
#include<fstream>
#define dim 30009
using namespace std;
int copil[dim],n,pas,k,x,nr,l;
int main()
{

    ifstream f("order.in");
    ofstream g("order.out");
    f>>n;
    //nr=n;
    for(int i=1;i<n;++i)
    copil[i]=i+1;
    copil[n]=1;
    pas=1;
    l=1;
    while(n)
    {

        x=pas;
        k=0;
        while
        (k<x-1)
        {
            k++;
            l=copil[l];
        }
        g<<copil[l]<<" ";
        copil[l]=copil[copil[l]];
        n--;
        pas++;
    }
}