Cod sursa(job #2489557)

Utilizator stefan1anubystefan popa stefan1anuby Data 8 noiembrie 2019 22:24:49
Problema Order Scor 25
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.47 kb
#include <fstream>
#include <algorithm>
#include <string>
using namespace std;
ifstream cin("order.in");
ofstream cout("order.out");
int v[30005];
int main()
{
    int n,i,j,x;
    cin>>n;
    j=x=1;
    for(i=1; i<=n; i++)
    {
        x=1;
        while(x<=i)
        {
            j++;
            if(j==n+1)
                j=1;
            if(v[j]==0)
                x++;
        }
        cout<<j<<" ";
        v[j]=1;
    }
    return 0;
}