Go: package main

import "fmt"

func main() {
	var w, n int
	fmt.Scan(&w)
	numbers := make([]int, w)

	fmt.Scan(&n)

	intersect := make([][2]int, n)

	for i := 0; i < n; i++ {
		var x, y int
		fmt.Scanf("%d,%d", &x, &y)
		intersect[i] = [2]int{x, y}
	}

	for i := 0; i < w; i++ {
		numbers[i] = i + 1
	}

	for _, v := range intersect {
		swap(numbers, v[0], v[1])
	}

	for _, v := range numbers {
		fmt.Println(v)
	}
}

func swap(arr []int, x, y int) {
	tmp := arr[x-1]
	arr[x-1] = arr[y-1]
	arr[y-1] = tmp
}

C++: #include <stdio.h>
void swap(int *a,int *b){
	int tmp;
	tmp=*a;*a=*b;*b=tmp;
	return;
}

int main(){
	int w,n,a,b,num[31],i;
	for(i=0;i<31;i++) num[i]= i;
	scanf("%d",&w);
	scanf("%d",&n);
	while(n--){
		scanf("%d,%d",&a,&b);
		swap(&num[a],&num[b]);
	}
	for(i=1;i<w+1;i++) printf("%d\n",num[i]);
	return 0;
}

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

int main()
{
	int w, n, a, b;
	char abdata;
	int wdata[1000];
	cin >> w >> n;
	for (int i = 0; i < w; i++) {
		wdata[i] = i+1;
	}
	for (int k = 0; k < n; k++) {
		int data;
		cin >> a >> abdata >> b;
		data = wdata[a-1];
		wdata[a-1] = wdata[b-1];
		wdata[b-1] = data;
	}
	for (int y = 0; y < w; y++) {
		cout << wdata[y] << endl;
	}
}

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];
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <sstream>
using namespace std;
int main() {
  int w;
  while (cin >> w) {
    vector<int> vec;
    vec.resize(w);
    for (int i = 0; i < vec.size(); ++i) {
      vec[i] = i + 1;
    }
    int n;
    cin >> n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
      string str, tmp_a, tmp_b;
      int a, b;
      getline(cin, str);
      istringstream iss(str);
      getline(iss, tmp_a, ',');
      getline(iss, tmp_b, ',');
      a = stoi(tmp_a) - 1;
      b = stoi(tmp_b) - 1;
      int tmp = vec[a];
      vec[a] = vec[b];
      vec[b] = tmp;
    }
    for (int i = 0; i < vec.size(); ++i) {
      cout << vec[i] << endl;
    }
  }
  return 0;
}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

int main() {
	int w, n;
	while(cin >> w) {
		cin >> n;
		vvi bar(n, vi(2));
		
		int a, b;
		char c;
		REP(i, n) {
			cin >> a >> c >> b;
			bar[i][0] = a;
			bar[i][1] = b;
		}

		vi goal(w);
		FOR(i, 1, w) {
			int cur = i;
			REP(j, n) {
				if(bar[j][0] == cur) {
					cur = bar[j][1];
					goto next;
				}
				if(bar[j][1] == cur) {
					cur = bar[j][0];
					goto next;
				}

				next:;
			}
			
			goal[cur-1] = i;
		}

		REP(i, w) {
			cout << goal[i] << endl;
		}
	}
}

C++: #include <bits/stdc++.h>

const static double	de_PI	= 3.14159265358979323846;
const static int	de_MOD	= 1000000007;
const static int	de_MAX	= 999999999;
const static int	de_MIN = -999999999;



int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());

	int w = 0, n = 0;
	char a, b, temp;
	std::cin >> w >> n;

	std::vector<int> A(w + 1);
	std::iota(A.begin(), A.end(), 0);

	for (int i = 0; i < n; i++) {
		std::cin >> a >> temp >> b;
		std::swap(A[a - '0'], A[b - '0']);
	}

	for_each(A.begin() + 1, A.end(),
		[](int &i) {
		std::cout << i << std::endl;
	}
	);

}

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

int main() {
	int w, n, x, y;
	string str;
	cin >> w >> n;
	int a[31];
	for (int i = 0; i <= w; i++) {
		a[i] = i;
	}														//1 = 49
	for (int i = 0; i < n; i++) {
		cin >> str;
		x = stoi(str);
		if (to_string(x).size()==1&&str.size()==3){
			int temp = str[2];
			y = temp-48;
		}
		else if(to_string(x).size()==2&&str.size()==4){
			int temp = str[3];
			y = temp - 48;
		}
		else if(to_string(x).size()==1&&str.size()==4){
			int juunokurai = str[2];
			int itinokurai = str[3];
			y = (juunokurai - 48) * 10 + (itinokurai - 48);
		}
		else {
			int juunokurai = str[3];
			int itinokurai = str[4];
			y = (juunokurai - 48) * 10 + (itinokurai - 48);
		}
		int tmp = a[x];
		a[x] = a[y];
		a[y] = tmp;
	}
	for (int i = 1; i <= w; i++) {
		cout << a[i] << endl;
	}
	return 0;
}

C++: #define scanf_s scanf
#include <stdio.h>
#include <string>
#include <iostream>
#include <math.h>
using namespace std;
#define MAX 30
int main(void)
{
	int w, n, a, b, x;
	int list[MAX] = { 0 };
	scanf_s("%d", &w);
	scanf_s("%d", &n);
	for (int i = 0; i < w;++i) {
		list[i] = i + 1;
	}
	for (int i = 0; i < n; ++i) {
		scanf_s("%d,%d", &a, &b);
		x = list[a - 1]; list[a - 1] = list[b - 1]; list[b - 1] = x;
	}
	for (int i = 0; i < w; ++i) {
		printf("%d\n", list[i]);
	}

}