Go: package main

import "fmt"

func main() {
	var w, n, a, b, i, te int
	var amida [31]int
	fmt.Scanf("%d", &w)
	fmt.Scanf("%d", &n)
	for i := 1; i <= w; i++ {
		amida[i] = i
	}
	for i := 1; i <= n; i++ {
		fmt.Scanf("%d,%d", &a, &b)
		te = amida[a]
		amida[a] = amida[b]
		amida[b] = te
	}
	for i := i; i <= w; i++ {
		fmt.Printf("%d\n", amida[i])
	}
}

C++: #include<iostream>
#include"Header.h"
using namespace std;
#define size_n 4
#define size_num 30

int main(){
	int swap_times;
	int num_length;
	char n[size_n]={'\0'};
	int num[size_num] = {0};
	int temp;
	cin >> num_length;
	cin >> swap_times;

	for(int i=1;i <= num_length;i++){
		num[i] = i;
	}

	for(int i=1;i<=swap_times;i++){
		cin >> n;
		temp					= num[(int)n[0]-(int)'0'];
		num[(int)n[0]-(int)'0'] = num[(int)n[2]-(int)'0'];
		num[(int)n[2]-(int)'0'] = temp;

		//データの初期化
		for(int i=0;i<size_n;i++){
			n[i] = '\0';
		}
	}

	for(int i=1;i<=num_length;i++){
		cout << num[i] << endl;
	}

	return 0;
}

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

int main(){
	int data[31];
	int w,n;
	cin >> w >> n;
	for(int i=1;i<=w;i++)
		data[i] = i;
		
	while(n--){
		int a,b;
		scanf("%d,%d\n",&a,&b);
		swap(data[a],data[b]);
	}
	for(int i=1;i<=w;i++)
		cout << data[i] << endl;
}

C++: #include<bits/stdc++.h>
using namespace std;

int c[32] = {0};

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

    return 0;
}

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

void swap(int &x, int &y) {
    x ^= y; y ^= x; x ^= y;
}

int main(void) {
    int select; scanf("%d", &select);
    int amida[select + 1];
    for(int r = 1; r <= select; r++) amida[r] = r;
    int horizon; scanf("%d", &horizon);
    for(int r = 0; r < horizon; r++) {
        int x, y; scanf("%d,%d", &x, &y);
        swap(amida[x], amida[y]);
    }
    for(int r = 1; r <= select; r++)cout << amida[r] << endl;
    return(0);
}

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

int main(){
  int a,b,m[31],c,e;
  string d;
  cin >>a>>b;
  for(int i=1;i<=a;i++)m[i]=i;
  for(int i=1;i<=b;i++){
    cin >>d;
    cout <<d[0]<<d[1]<<d[2]<<endl;///////
    swap(m[d[0]-'0'],m[d[2]-'0']);
  }
  for(int i=1;i<=a;i++)cout<<m[i]<<endl;
  return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(void){
    int w[30],a,b,tmp,d,n;
    char c;
    cin >> d >> n;
    for(int i=0; i<d; i++)
        w[i] = i+1;
    for(int i=0; i<n; i++){
        cin >> a >> c >> b;
        tmp = w[a-1]; w[a-1] = w[b-1]; w[b-1] = tmp;
    }
    for(int i=0; i<d; i++)
        cout << w[i] << endl;
}

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

void swap(int *a, int *b){
  int tmp;
  tmp = *a;
  *a = *b;
  *b = tmp;
}

int main(){

  int w,n;
  cin >> w;
  cin >> n;

  int list[40];
  for(int i = 0; i < 40 ; i++){
    list[i] = i;
  }

   int a,b;
   char tmp;
   while( cin >> a >> tmp >> b ){
    swap( &list[a], &list[b] );
  }
  
  for(int  i = 1; i <= w ; i++ ){
    cout << list[i] << endl;
  }
  
  return 0;
}

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

int main(){
	int amida[30];
	for (int i = 0; i < 30; i++){
		amida[i] = i + 1;
	}
	int n, w;
	int a, b;

	cin >> w;
	cin >> n;
	int c;
	for (int i = 0; i < n; i++){
		char c;
		cin >> a >> c >> b;
		swap(amida[a - 1], amida[b - 1]);
	}
	for (int i = 0; i < w; i++){
		cout << amida[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 ;
  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];
      }
    }
    v[num-1] = i+1;
  }
  for(int i = 0;i < v.size();++i){
    cout << v[i] << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>

int main(int argc, const char * argv[]) {
    std::vector<int> r;
    int w,n;
    int a,b;
    std::cin >> w >> n;
    for(int i = 0;i <= w;i++){
        r.push_back(i);
    }
    for(int i = 0; i <= n; i++){
        (std::cin >> a).ignore()>>b;
        std::swap(r[a],r[b]);
    }
    for(int i = 0; i <=w;i++){
        std::cout<< r[i] << std::endl;
        
    }
}

C++: #include <iostream>
#include<math.h>
#include <vector>
#include <string>
#include<stdio.h>
using namespace std;

class Amidakuji{

public:
	int W;
	vector<int> array;//????´?1???????????????
	Amidakuji(int w);
	void Swap(int x,int y);
	void call();
};

//????????????????????????????????????
Amidakuji::Amidakuji(int w){

	for (int i = 0; i < w; i++){
		array.push_back(i+1);//[0,1,2,3,4]={1,2,3,4,5}
	}
	
	W = w;

}

void Amidakuji::Swap(int x,int y){

	//???????????£????????????array[]???????????????
	//int?????§???????????£????????§char???int?????????????????????-48;
	
	int q;
	q = array[x - 1];
	array[x-1] = array[y-1];
	array[y-1] = q;
	

}

void Amidakuji::call(){

	for (int i = 0; i<W; i++){
		cout << array[i] << endl;
	}

}

int main(){


	int w, n,loc,a,b;
	string text,str_a,str_b,str_v;

	while (cin >> w>>n){
		cin.ignore();
		//??????????????????????????§???????????????
		Amidakuji Amidakuji(w);
		for (int i = 0; i < n; i++){
			getline(cin, text);

			//????????¶?????§??????10,2??????????????¨??????{1,0,,,2}??????????????¢????????£?????????????????§??????????????????????????????????????????

			//?????????????????????????????????????????????????????§?????????????????£?????????????????\????????????????????£???
			loc=text.find(",", 0);
			str_a = text[0];
			for (int j = 1; j < loc; j++){
				str_v = text[j];
				str_a = str_a + str_v;

			}
			str_b = text[loc + 1];
			for (int j = loc + 2; j < text.length(); j++){
				str_v = text[j];
				str_b = str_b + str_v;
			}

			
			a = stoi(str_a);
			b = stoi(str_b);


			if (a != 0 && b != 0){
				//???????????????????????????swap???????????????
				Amidakuji.Swap(a, b);
				a = b = 0;
			}
		}
	
		//????????????
		Amidakuji.call();
	}

	



	return 0;
}

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

int main(){

  int w, n, a, b;
  int x[30];
  char c;

  cin>>w>>n;

  for(int i=0;i<w;i++) x[i]=i+1;
  
  for(int i=0;i<n;i++){
    cin>>a>>c>>b;
    swap(x[a-1], x[b-1]);
  }

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

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

int main(){
	int w;
	int n;
	int a, b;

	cin >> w >> n;
	
	int number[30];
	for(int i = 0; i < w; i++){
		number[i] = i+1;
	}

	for(int i = 0; i < n; i++){
		scanf_s("%d,%d", &a, &b);
		swap(number[a-1], number[b-1]);
	}
	
	for(int i = 0; i < w; i++){
		cout << number[i] << endl;
	}

	return(0);
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main()
{
	int w, n, cp, amd[30] = {0}, yoko[2];
	
	cin >> w >> n;

	for(int i = 1; i <= w; i++)
		amd[i-1] = i;

	for(int i = 0; i < n; i++){
		scanf("%d,%d", &yoko[0], &yoko[1]);

		cp = amd[yoko[0]-1];
		amd[yoko[0]-1] = amd[yoko[1]-1];
		amd[yoko[1]-1] = cp;
	}

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