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>

int main(void) {
  int i, n, j, k, w;
  scanf("%d%d", &w, &n);
  int a[n], b[n], now, ans[w + 2];
  for(i = 0; i < n; ++i) scanf("%d,%d", &a[i], &b[i]);
  for(i = 1; i <= w; ++i) {
    now = i;
    for(j = 0; j < n; ++j) {
      if(a[j] == now) now = b[j];
      else if(b[j] == now) now = a[j];
    }
    ans[now] = i;
  }
  for(i = 1; i <= w; ++i) printf("%d\n", ans[i]);
  return 0;
}

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

inline void change(int array[], int a, int b){
  int c = array[a];
  array[a] = array[b];
  array[b] = c;
}

int main(){
  int array[MAX];
  int w, n, a, b;
  char comma;

  cin >> w >> n;

  for(int i = 0; i < w; i++){
    array[i]=i+1;
  }

  for(int i=0; i<n; i++){
    cin >> a >> comma >> b;
    change(array, a-1, b-1);
  }

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

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

int main(){

	int w, n;
	int num[30] = { 0 };
	int a, b;
	char c;

	cin >> w;
	cin >> n;

	for (int i = 0; i<w; i++)
		num[i] = i + 1;

	for (int i = 0; i<n; i++){

		cin >> a >> c >> b;


		int tmp = num[a-1];
		num[a-1] = num[b-1];
		num[b-1] = tmp;


	}


	for (int i = 0; i<w; i++)
		cout << num[i] << "\n";

	return 0;

}

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

int main() {
  int w, n;
  cin >> w >> n;
  int a[n], b[n];

  for (int i=0; i<n; i++) {
    string s;
    cin >> s;
    a[i] = s[0] - '1'; b[i] = s[2] - '1';
  }
  for (int i=0; i<w; i++) {
    int p = i;
    for (int j=n-1; j>=0; j--) {
      if (p == a[j])
        p = b[j];
      else if (p == b[j])
        p = a[j];
    }
    cout << p + 1 << endl;
  }
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main() {
int w, n;
while (cin >> w >> n) {
vector<int> vec;
for (int i = 0; i < w; ++i) {
  vec.push_back(i + 1);
}
for (int i = 0; i < n; ++i) {
  int a, b;
  scanf("%d,%d", a, b);
  a -= 1;
  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<iostream>
using namespace std;
void swap(int* a,int* b){
	int t=*a;
	*a=*b;
	*b=t;
	}
int main(){
	int w;
	int n;
	int c[30];
	int a;
	int b;
	scanf("%d",&w);
	scanf("%d",&n);
	for(int i=0;i<=w;i++){
		c[i]=i;
		}
	for(int i=0;i<n;i++){
		(cin>>a).ignore()>>b;
        swap(c[a],c[b]);
       }
     for(int i=1;i<=w;i++){
     	cout<<c[i]<<endl;
     }
     return 0;
    }

C++: #include <stdio.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>

using namespace std;

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

C++: #include <iostream>
#include <vector>
//#include <math.h>
//#include <string>
#include <cmath>
#include <iomanip>

int main();

//最初に素数リストを作成し、入力された値に対してリストを参照する。
int main(){
	int w;		//縦線の本数
	int n;		//横棒の本数
	int lines[31];		//ライン番号

	std::cin >> w >> n;
	
	//ライン番号初期化
	//範囲に注意
	for (int i = 1; i <= w; i++){
		lines[i] = i;
	}
	for (int i = 0; i < n; i++){
		int x;
		int y;
		char comma;

		std::cin >> x >> comma >> y;
		//交換処理
		int temp;
		temp = lines[x];
		lines[x] = lines[y];
		lines[y] = temp;
	}
	//結果出力
	//範囲に注意
	for (int i = 1; i <= w; i++){
		std::cout << lines[i] << std::endl;
	}

	//while (1);
	return 0;
}

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

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

C++: #include<stdio.h>

int main(){
int tate,yoko,bou[30][2],j,x,kekka[]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30},i=0;
scanf("%d %d",&tate,&yoko);
for(j=0;j<yoko;j++){
scanf("%d , %d",&bou[j][1],&bou[j][2]);
}
for(i=1;i<tate+1;i++){
x=i;
for(j=0;j<yoko;j++){
if(bou[j][1]==x){
x=bou[j][2];
}
else if(bou[j][2]==x){
x=bou[j][1];
}
}
kekka[x-1]=i;
}
for(j=0;j<tate;j++){
printf("%d\n",kekka[j]);
}
}

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

int main(){
  int w,n;
  int a[30],b[30],ans[100],tmp;
  cin >> w >> n;

  for(int i=0;i<n;i++)scanf("%d,%d",&a[i],&b[i]);
  

    for(int j=1;j<=w;j++){
      tmp=j;
      for(int i=0;i<n;i++){
	if(j==a[i]||j==b[i]){
	  if(j!=a[i])j=a[i];
	  else j=b[i];
	}
      }
      ans[j]=tmp;
      j=tmp;
    }
    for(int i=1;i<=w;i++)cout << ans[i]<<endl;


  return 0;
}

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

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

C++: #include <iostream>

using namespace std;

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

int main()
{
	int w,n;
	int a,b;
	int perm[31];
	char dummy;
	
	cin >> w >> n;
	
	for (int i=1; i<=w; i++) perm[i] = i;
	
	for (int i=0; i<n; i++) {
		cin >> a >> dummy >> b;
		swap(perm[a], perm[b]);
	}
	
	for (int i=1; i<=w; i++) cout << perm[i] << endl;
	
	return 0;
}

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

void swap(int*,int*,int);
int main()
{
  int w,n,i;
  cin>>w>>n;
  int *numline = new int;
  for(i=0;i<w;++i){
    numline[i]=i+1;
  }
  int *swapline = new int;
  for(i=0;i<2*n;i+=2){
    char innum[10];
    cin >>innum;
    int m=0;
    while(innum[m]!=',') ++m;
    if(m==1){
      swapline[i]=innum[0]-48;
      if(strlen(innum)-m-1==1) swapline[i+1]=innum[2]-48;
      else swapline[i+1]=10*(innum[2]-48)+(innum[3]-48);
    }
    else{
      swapline[i]=10*(innum[0]-48)+(innum[1]-48);
      if(strlen(innum)-m-1==1) swapline[i+1]=innum[3]-48;
      else swapline[i+1]=10*(innum[3]-48)+(innum[4]-48);
    }
  }
  swap(numline,swapline,n);
  for(i=0;i<w;++i){
  cout<<numline[i]<<endl;
  }
  delete numline;
  delete swapline;
  return 0;
}

void swap(int numline[],int swapline[],int n)
{
  for(int i=0;i<2*n;i+=2){
    swap(numline[swapline[i]-1],numline[swapline[i+1]-1]);
  }
}

C++: #include<iostream>
#include<stdio.h>

int main(){

  int w,n,a,b,tmp;
  std::cin >> w >> n;

  int tate[w];

  for(int i=0;i<w;i++){
    tate[i]=i+1;
  }

  for(int i=0;i<n;i++){
    scanf(" %d,%d",&a,&b);
    tmp = tate[a-1];
    tate[a-1] = tate[b-1];
    tate[b-1] = tmp;
  }

  for(int i=0;i<w;i++){
    std::cout << tate[i] << std::endl;
  }


}