Pagini recente » Autentificare | Cod sursa (job #1668232) | Cod sursa (job #2126314) | Cod sursa (job #1177935) | Cod sursa (job #1074512)
#include <iostream>
#include <stdio.h>
#include <malloc.h>
#include <fstream>
using namespace std;
fstream f("schi.in",ios::in);
fstream g("schi.out",ios::out);
struct node{
int info;
int poz;
struct node *next;
}*first,*p;
void add(int poz, int inf)
{
node *n=(node *)malloc(sizeof(node));
n->info=inf;
n->poz=poz;
if(first!=NULL){
p=first;
if(first->info>inf){
n->next=first;
first=n;
}
else{
while(p->next!=NULL&&p->next->info<inf)p=p->next;
n->next=p->next;
p->next=n;
}
}
else{
first=n;
first->next=NULL;
}
}
void print()
{
p=first;
while(p!=NULL){
g<<p->poz;
p=p->next;
}
}
int main()
{
int info,n,a,i;
f>>n;
f>>a;
add(a,1);
for(i=2;i<=n;i++)
{
f>>a;
add(i,a);
}
print();
return 0;
}