Go: package main

import (
        "fmt"
)

const MAX_N = 31
var lines [MAX_N]int

func main() {
        var n, w int
        fmt.Scanf("%d", &n)
        fmt.Scanf("%d", &w)

        Init()
        var l, r int
        for {
                _, err := fmt.Scanf("%d,%d", &l, &r)
                if err != nil {
                        break
                }

                Swp(l, r)
        }

        for i := 1; i <= n; i++ {
                fmt.Printf("%d\n", lines[i])
        }
}

func Swp(l int, r int) {
        var s int
        s = lines[l]
        lines[l] = lines[r]
        lines[r] = s
}

func Init() {
        for i := 0; i < MAX_N; i++ {
                lines[i] = i
        }
}

C++: #include<cstdio>
int main(){
    int w,n;
    scanf("%d%d",&w,&n);
    int *ar=new int[w];
    for(int i=0;i<w;i++){
        ar[i]=i+1;
    }
    for(int i=0;i<n;i++){
        int a,b,t;
        scanf("%d,%d",&a,&b);
        t=ar[a-1];
        ar[a-1]=ar[b-1];
        ar[b-1]=t;
    }
    for(int i=0;i<w;i++){
        printf("%d\n",ar[i]);
    }
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
typedef long long int LLI;
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int n,m;
  char d;
  cin>>n>>m;
  vector<int>out(n);
  rep(i,n)out[i]=i+1;
  rep(i,m){
    int a,b;
    cin>>a>>d>x>b;
    swap(out[a-1],out[b-1]);
  }
  rep(i,n)cout<<out[i]<<endl;
}

C++: #include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<math.h>

using namespace std;

typedef long long int lli;

int main() {
	int w, n;
	cin >> w >> n;
	vector<int> ar(w);
	vector<vector<int>> hor(n,vector<int>(2));
	for (int i = 0; i < w; i++) ar[i] += i+1;
	for (int j = 0; j < n;j++) {
		(cin >> hor[j][0]).ignore(1) >> hor[j][1];
		swap(ar[hor[j][0]-1], ar[hor[j][1]-1]);
	}
	for (int i = 0; i < w; i++) cout << ar[i] << endl;
	return 0;
}

C++: #include<iostream>
using namespace std;

int main(void){
	int w,n,x,y,temp;
	int a[31];
	char c;
	string str;
	istringstream is(str);
	for(int i = 0; i < 31; i++){
		a[i] = i;
	}
	scanf("%d %d",&w,&n);
	for(int i = 0; i < n; i++){
		getline(str,7);
		is >> x >> c >> y;
		temp = a[x];
		a[x] = a[y];
		a[y] = temp;
	}

	for(int i = 0; i < w; i++){
		cout << a[i + 1] << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;

int main(){
	int w, n;
	int a[30], b[30];
	int p, q, r;
	int base[31];

	base[0] = 0;
	w = 0; n = 0;

	cin >> w;
	cin >> n;

	for (int i = 0; i <= w; i++){
		base[i] = i;
	}
	for (int i = 0; i<n; i++){
		cin >> a[i] >> b[i];
	}

	for (int i = 0; i<n; i++){
		p = a[i]; q = b[i];
		r = base[p];
		base[p] = base[q];
		base[q] = r;
	}

	for (int i = 1; i <= w; i++){
		cout << base[i];
		if (i != w){
			cout << " ";
		}
		if (i == w){
			cout << "\n";
		}
	}

	return 0;
}

C++: #include<stdio.h>
#include<math.h>
struct shu
{
int from;
int to;
};
shu nCost[31];
void vmake(int nN,int nC);
int main()
{
	int num,nCase,i;

	while(scanf("%d",&num)==1)
	{
      scanf("%d",&nCase);
	  for(i=1;i<=nCase;i++)
	  {
	    scanf("%d,%d",&nCost[i].from,&nCost[i].to);
	  }
	    vmake(num,nCase);
	 }
	return 0;
}

void vmake(int nN,int nC)
 {
  int i,j,To;
  for(i=1;i<=nN;i++)
  {  
     To=i;
     for(j=nC;j>=1;j--)
	 {
       if(To==nCost[j].from)
	         To=nCost[j].to;
	   else
	      if(To==nCost[j].to)
	         To=nCost[j].from;
	 }
	 printf("%d\n",To);
  }
 }

C++: #include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
  
using namespace std;
  
int main(){
  
    int w,n,left,right;
    scanf("%d",&w);
    int array[w+1];
    for(int i=0;i<w+1;i++)array[i]=i;
    scanf("%d",&n);
  
    for(int i=0;i<n;i++){
        scanf("%d,%d",&left,&right);
        swap(array[left],array[right]);
    }
  
    for(int i=1;i<=w;i++){
        printf("%d\n",array[i]);
    }
  
    return 0;
}

C++: #include <iostream>
#include <algorithm>
#define MAX 31

using namespace std;

int main(void){

  int N[MAX];
  int w,n;
  int a,b;
  char ten;

  cin >> w >> n;
  for( int i = 1 ; i <= w ; i++ )N[i] = i;

  for( int i = 1 ; i <= n ; i++ ){
    cin >> a >> ten >> b;
      swap( N[a] , N[b]); //swap関数は第一引数と第二引数を交換する関数
  }
  for( int i = 1 ; i <= w ; i++ ){
    cout << N[i] << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>

using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()

#define rep(i,n) for(int i = 0; i < (n);++i)
#define repc(i,a,b) for(int i = (a);i <(b);++i)
#define repa(n,array) for(auto n :(array))

typedef long long ll ;
typedef vector<int> vi ;
typedef vector<ll> vl ;

const int IMAX = ((1<<30)-1)*2+1 ;
const int INF = 100000000;
double EPS = 1e-10 ;

int main(){
  char c;
  int w,n,a,b,num,ans[5];
  bool flag = true;
  cin >> w >> n;
  vi v(w,0),va,vb ;
  rep(i,n){
    cin >> a >> c >> b ;
    va.pb(a),vb.pb(b) ;
  }

  rep(i,w){
    num = i+1 ;
    rep(j,n){
      if(num == va[j]){
        num = vb[j];
      }
      else if(num == vb[j]){
        num = va[j];
      }
    }
    ans[num-1] = i+1;
  }
  repa(tmp,ans){
    cout << tmp << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <stack>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <vector>

using namespace std;






int main()
{
	int n, w;
	int a[30], b[30],c[30];
	cin >> w;
	cin >> n;
	for (int i = 0; i < n; i++) {
		scanf("%d,%d", &a[i], &b[i]);
		
	}
	for (int i = 1; i <= w; i++) {
		c[i] = i;
	}
	for (int i = 0; i < n; i++) {
		swap(c[a[i]], c[b[i]]);
	}
	for (int i = 1; i <= w; i++) {
		cout << c[i] << endl;
	}
	

}

C++: #include <iostream>
using namespace std;

int main()
{
	int w, n, z;
	char c[30];
	int N[30];
	int a[30], b[30];
	cin >> w >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i] >> c[i] >> b[i];
	}
	for (int i = 1; i <= w; i++)
	{
		N[i] = i;
	}
	for (int i = 0; i < n; i++)
	{
		z = N[a[i]];
		N[a[i]] = N[b[i]];
		N[b[i]] = z;
	}
	for (int i = 1; i <= w; i++)
	{
		cout << N[i] << endl;
	}
}

C++: // 0011.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
#include <typeinfo>
using namespace std;
#define ll long long
#define ld long double
#define roop(a,t) for(ll a=0;a<t;a++)
int main()
{
	ll w, n;

	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> w >> n;
	ll a[32];
	roop(i, 32) {
		a[i] = i + 1;
	}
	roop(i, n) {
		string s;
		cin >> s;
		string d[2];
		roop(i, s.length()) {
			if (s[i] == ',') { d[0] = s.substr(0, i); d[i] = s.substr(i + 1); break; }
		}
		ll swap[2];
		roop(i, 2) {
			swap[i] = stoll(d[i]);
		}
		ll before = a[swap[0] - 1];
		a[swap[0] - 1] = a[swap[1] - 1];
		a[swap[1] - 1] = before;
	}
	roop(i, n) {
		cout << a[i] << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
 
int main()
{
    int w,n;
 
    char c;
 
  cin >> w >> n;
 
 vector<int> a(n);
 
    vector<int> b(n);
 
    vector<int> x(w);
 
    for(int i=0;i<n;++i)
    {
        std::cin >> a[i] >> c >> b[i];
    }
 
    for(int i=0;i<w;++i)
    {
        x[i]=i+1;
    }
 
    for(int i=0;i<n;++i)
    {
        int temp = x[a[i]-1];
 
        x[a[i]-1]=x[b[i]-1];
 
        x[b[i]-1]=temp;
    }
 
    for(int i=0;i<w;++i)
    {
      cout << x[i] << endl;
    }
}