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<algorithm>
#include<stdio.h>

#define MAX 30
#define rep(i, a) for(int i = 0; i < (a); ++i)
#define rept(i, a, b) for(int i = (a); i <= (b); ++i)

int main(){
	int w, n;
	int num[MAX];
	int a, b;
	std::cin >> w >> n;
	rep(i, MAX)
		num[i] = i + 1;		
	rep(i, n){
		scanf("%d,%d", &a, &b);
		std::swap(num[a - 1], num[b - 1]);
	}
	rep(i, w)
		std::cout << num[i] << std::endl;
	return 0;
}

C++: #include<iostream>

using namespace std;
int data[40];
int main(){

	for(int i=0;i<40;i++)data[i]=i;
	int w;
	int n;
	cin>>w;
	cin>>n;
	for(int i=0;i<n;i++){
		char tmp[4];
		cin>>tmp;
		int a=tmp[0]-'0';
		int b=tmp[2]-'0';
		int t=data[a];
		data[a]=data[b];
		data[b]=t;
	}
	
	for(int i=1;i<=w;i++)cout<<data[i]<<endl;
}

C++: #include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
#define FOR(i, s, e) for(int i = s; i < e; ++i)
void getValues(string& s, int& a, int & b)
{
	string::size_type p = s.find(',');
	string sa = s.substr(0, p);
	string sb = s.substr(p + 1);
	a = atoi(sa.c_str());
	b = atoi(sb.c_str());
}

int main()
{
	int w, n, a, b;
	cin >> w >> n;
	int W[31] = {};
	FOR(i, 1, w + 1) W[i] = i;
	string line;
	while (n--){
		cin >> line;
		getValues(line, a, b);
		swap(W[a], W[b]);
	}
	FOR(i, 1, w + 1) cout << W[i] << "\n";
	return 0;
}

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

int main()
{
  int width,number;
  cin >> width >> number;
  int change[number][2];
  string str;
  for(int i=0; i<number; i++){
    scanf("%d,%d",&change[i][0],&change[i][1]);
  }
  int bou[width+1];
  for(int i=0; i<width+1; i++){
    bou[i] = i;
  }
  int temp;
  for(int i=0; i<number; i++){
    temp = bou[change[i][0]];
    bou[change[i][0]] = bou[change[i][1]];
    bou[change[i][1]] = temp;
  }

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

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

#define swap(a,b) a^=b^=a^=b

using namespace std;

int main(){
    
    int w,n,a,b;
    cin >> w >> n;
    int *ans = new int(w+1);


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

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

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

int w, n, l[31];

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

	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS 1

#include <cstdio>

using namespace std;

int main()
{
	int W, N, A[31], B[31], C[31];

	scanf("%d", &W);
	scanf("%d", &N);

	for (int i = 1; i <= N; i++)
	{
		scanf("%d,%d", &(A[i]), &(B[i]));
	}

	for (int i = 1; i <= W; i++)
	{
		int t = i;

		for (int j = 1; j <= N; j++)
		{
			if (A[j] == t)
			{
				t = B[j];
			}
			else if (B[j] == t)
			{
				t = A[j];
			}
		}

		C[t] = i;
	}

	for (int i = 1; i <= W; i++)
	{
		printf("%d\n", C[i]);
	}

	return 0;
}

C++: // あみだくじ。

#include <iostream>
#include <cstdio>
using namespace std;

int main(void) {
    int w, n;
    int* vertical;
    int a, b, tmp;
    
    cin >> w;
    vertical = new int[w + 1];
    for(int i = 0; i <= w; ++i) {
        vertical[i] = i;
    }
    cin >> n;
// scanfの""内に','を入れることで入力の仕方をa,bにすることが出来る。abはエラー
    for(int i = 0; i < n; ++i) {
        scanf("%d,%d", &a, &b);
        tmp         = vertical[a];
        vertical[a] = vertical[b];
        vertical[b] = tmp;
    }
    for(int i = 1; i <= w; ++i) {
        cout << vertical[i] << endl;
    }
}

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++: //============================================================================
// Name        : desk.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<stdio.h>
#include<iostream>
#include <algorithm>
using namespace std;
int main(){
int w,n;
cin>>w>>n; //w????¨???????n????????\?????????????????°
int N[w]; //???????????°
for(int i=0;i<w;i++){
	N[i]=i+1; //?¨??????°?????\???????§?
}
for(int i=0;i<n;i++){
	int a,b;
	char c;
	cin>>a>>c>>b; //char???,?????\????????¨
	swap(N[a-1],N[b-1]); //swap??§??´??\??\?????????
}
for(int i=0;i<w;i++){
	cout<<N[i]<<endl; //?????¨?????????
}
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>
#include <cmath>

int main(void)
{
  int w, n;

  std::cin >> w >> n;

  std::vector<int> base;
  for (int i = 0; i < w; i++) {
    base.push_back(i + 1);
  }

  for (int i = 0; i < n; i++) {
    int a, b;
    scanf_s("%d,%d", &a, &b);
    std::swap(base[a - 1], base[b - 1]);
  }

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

  return 0;
}

C++: // 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
#ifdef DAIJOBU
#include "/home/v-o_o-v/deb.h"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif 

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	int w;
	cin >> w;
	vector<int> A;
	for(int i = 1; i <= w; i++)A.push_back(i);
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		string s;
		cin >> s;
		string a, b;
		for(int j = 0; j < (int)s.size(); j++){
			if(s[j] == ','){
				a = s.substr(0, j);
				b = s.substr(j + 1);
				break;
			}
		}
		int x = stoi(a), y = stoi(b);
		x--;
		y--;
		swap(A[x], A[y]);
	}
	for(int i = 0; i < w; i++)cout << A[i] << '\n';
	return 0;
}
// Write Here

C++: #include <iostream>
#include <stdlib.h>
#include <string>
#include <strstream>

using namespace std;

int main(int argc, char **argv)
{
	int n, w;
	int *goal, **line;
	string str, st1, st2;
	
	cin >> w;
	cin >> n;
	
	goal = (int *)calloc(w, sizeof(int));
	line = (int **)calloc(n, sizeof(int));
	for(int i = 0; i < n; i++){
		line[i] = (int *)calloc(2, sizeof(int));
		cin >> str;
		st1 = str[0];
		st2 = str[2];
		istrstream istr1(st1.data());
		istrstream istr2(st2.data());
		istr1 >> line[i][0];
		istr2 >> line[i][1];
	}
	
	for(int i = 1, tmp = 0; i <= w; i++){
		tmp = i;
		for(int j = 0; j < n; j++){
			if(tmp == line[j][0]){
				tmp = line[j][1];
			} else if(tmp == line[j][1]){
				tmp = line[j][0];
			}
		}
		goal[tmp-1] = i;
	}
	
	for(int i = 0; i < w; i++){
		cout << goal[i] << endl;
	}
	
	free(goal);
	for(int i = 0; i < n; i++){
		free(line[i]);
	}
	free(line);
	
	return 0;
}