Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C by registered user leoho15 ( 5 years ago )
#include<stdio.h>
int main(){
    int M,N,a,b;
    int s,c,t;
    int p[1000];
    scanf("%d %d\n",&N,&M);
    for(c=1;c<=N;c++){
        p[c-1]=c;
    }
    scanf("%d %d",&a,&b);
    while(1){
        M--;
        t=p[a-1];
        p[a-1]=p[b-1];
        p[b-1]=t;
        if(M==0)
          break;
        else
          scanf("%d %d",&a,&b);
    }
    for(c=1;c<=N;c++){
        printf("%d ",p[c-1]);
    }
    printf("\n");
    return 0;

}

 

Revise this Paste

Children: 119986
Your Name: Code Language: