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 <iostream>
#include <cstring>
#include <cmath>

using namespace std;

int main()
{
    int w, n, a, b, i, j, len, arr[32], temp;
    char pair[10];

    cin>>w>>n;

    for(i=1; i<=w; i++)
        arr[i] = i;

    for(i=1; i<=n; i++)
    {
        cin>>pair;

        a = 0;
        b = 0;

        len = strlen(pair);

        for(j=len-1; pair[j]!=','; j--)
        {
            b = b+ (pair[j] - '0') * pow(10, len-1-j);
        }

        len = j;

        for(j=len-1; j>=0; j--)
        {
            a = a+ (pair[j] - '0') * pow(10, len-1-j);
        }

        temp = arr[a];
        arr[a] = arr[b];
        arr[b] = temp;
    }

    for(i=1; i<=w; i++)
        cout<<arr[i]<<endl;

    return 0;
}

C++: #include<iostream>
using namespace std;
int n;
int a[1000000];
int sum[1000000];
int main(int argc, char const *argv[])
{

	int tc[30];
	cin>>tc[30];
	int w,v;
	for (int i = 0; i < 30; ++i) tc[i] = i+1;
		for (int i = 0; i < v; ++i)
		{
			int a,b;
			cin>>a>>b;
			int c=tc[a-1];
			tc[a-1]=tc[b-1];
			tc[b-1];

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

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

#define add push_back
#define inf 2147000000

#define rep(i,n) for(int i=0;i<n;i++)
#define out(a) cout<<a<<endl;

using namespace std;

int main(void){
	int w,h;
	int y1[30],y2[30],t[31];
	string str;
	scanf("%d%d",&w,&h);
	rep(i,h){
		cin>>str;
		y1[i] = str[0]-48;
		y2[i]=0;
		if(str[3]!='\0'){
			y2[i] = (str[2]-48)*10;
			y2[i]+=str[3]-48;
		}else{
			y2[i] = str[2]-48;
		}
	}
	rep(i,31)t[i]=i;
	
	rep(i,h){
		swap(t[y1[i]],t[y2[i]]);
	}
	
	rep(i,w)out(t[i+1]);
}

C++: #include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
#define scanf scanf_s

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

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

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

int swap(int* x, int* y){
	int tmp = *y;
	*y = *x;
	*x = tmp;
}
	
int main(){
	int w, n, array[31];
    int a, b;
    
    char sep;
    
	for(int i=1; i<=30; i++){
		array[i] = i;
	}
	
	cin >> w;
	cin >> n;
	
	while(0<n){
		cin >> a >> sep >> b;
		
		swap(&array[a], &array[b]);
		--n;
	}
	
	for(int j=1; j<=w; j++){
		cout << array[j] << endl;
	}
	return 0;
}

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

#define ll long long
#define LL long long
#define ULL unsigned long long 
#define ull unsigned long long 
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define int(x) int x;scanf("%d",&x);
#define double(x) double x;scanf("%lf",&x);
#define string(x) double string;cin>>x;

using namespace std;

int main()
{
	int w, n;
	int tmp[100] = {};
	scanf("%d %d", &w, &n);
	int a[100], b[100];
	int tmp_num;
	REP(i, w) {
		tmp[i] = i + 1;
	}
	for (int i = 0; i < n; i++) {
		scanf("%d,%d", &a[i], &b[i]);
	}

	for (int i = 0; i < n; i++) {
		tmp_num = tmp[a[i]-1];
		tmp[a[i]-1] = tmp[b[i]-1];
		tmp[b[i]-1] = tmp_num;
	}
	
	REP(i, w) {
		cout << tmp[i] << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#define N 30
using namespace std;
int main(){
????int w,n,tmp;
????int lod[N]; int lis[N][3];
????while(cin >> n >> w){
????for(int i = 0;i<n;i++){
????lod[i] = i+1;
????}
????for(int i=0;i<w;i++){
????scanf("%d,%d",&lis[i][0],&lis[i][2]);
????}
????for(int i=0;i<w;i++){
????tmp = lod[lis[i][0]-1];
????lod[lis[i][0]-1] = lod[lis[i][2]-1];
????lod[lis[i][2]-1] = tmp;
????}
????for(int i=0;i<n;i++){
????cout << lod[i] << endl;
????}
}

C++: #include <stdio.h>

int main(){
	int w, n;
	scanf("%d", &w);
	int *l = new int[w];
	for(int i = 0; i < w; i++){
		l[i] = i + 1;
	}
	scanf("%d", &n);
	int a, b;
	for(int i = 0; i < n; i++){
		scanf("%d,%d", &a, &b);
		int temp = l[a - 1];
		l[a - 1] = l[b - 1];
		l[b - 1] = temp;
	}
	for(int i = 0; i < w; i++){
		printf("%d\n", *(l++));
	}
	return 0;
}

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

using namespace std;

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

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

int main() {
	int w, n, a, b, c[31], i, d;
	char e;
	cin >> w >> n;
	for (i = 1; i <= w; i++) {
		c[i] = i;
	}
	for (i = 0; i < n; i++) {
		cin >> a >> e >> b;
		d = c[a];
		c[a] = c[b];
		c[b] = d;
	}
	for (i = 1; i <= w; i++) {
		cout << c[i] << 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;
	}
	for (int i = 0; i < n; i++) {
		cin >> str;
		x = str[0] - 48;
		y = str[2] - 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++: #include<iostream>
#include<stdio.h>
#define N 30
using namespace std;
int main(){
????int w,n,tmp;
????int lod[N]; int lis[N][3];
????while(cin >> n >> w){
????for(int i = 0;i<n;i++){
????lod[i] = i+1;
????}
????for(int i=0;i<w;i++){
????scanf("%d,%d",&lis[i][0],&lis[i][2]);
????}
????for(int i=0;i<w;i++){
????tmp = lod[lis[i][0]-1];
????lod[lis[i][0]-1] = lod[lis[i][2]-1];
????lod[lis[i][2]-1] = tmp;
????}
????for(int i=0;i<n;i++){
????cout << lod[i] << endl;
????}
  return 0;
}

C++: #include <iostream>
 
using namespace std;
 
int main(void)
{
  char hoge;
  int v, h, a, b, tmp;
  cin >> v;
  cin >> h;
    
  int bar[v];
  for (int i = 0; i < v; i++)
    bar[i] = i+1;
      
  for (int i = 0; i < h; i++) 
  {
    cin >> a >> hoge >> b;
    tmp = bar[a-1];
    bar[a-1] = bar[b-1];
    bar[b-1] = tmp;
  }
    
  for (int i = 0; i < v; i++)
    cout << bar[i] << endl;
   
  return 0;
}

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

int main() {
  int w, n, a, b;
  char c;
  std::cin >> w >> n;
  int d[w + 1];
  for (int i = 0; i <= w; i++) {
    d[i] = i;
  }
  for (int i = 0; i < n; i++) {
    std::cin >> a >> c >> b;
    std::swap(d[a], d[b]);
  }
  for (int i = 1; i <= w; i++) {
    std::cout << d[i] << std::endl;
  }
}