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>
int main(){int t[31],w=1,n,a,b,c;for(;w<31;)t[w]=w++;for(std::cin>>w>>n;n--;){(std::cin>>a).ignore(1)>>b;c=t[a];t[a]=t[b];t[b]=c;}for(n=1;n<w+1;)std::cout<<t[n++]<<'\n';}

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

int main(void){
	int a[30];
	int w,n;
	cin >> w >> n;
	for(int i=0;i<w;i++){
		a[i]=i;
	}
	for(int i=0;i<n;i++){
		int x,y,tmp;
		scanf("%d,%d",&x,&y);
		tmp = a[x-1];
		a[x-1] = a[y-1];
		a[y-1] = tmp;
	}
	for(int i=0;i<w;i++) cout << a[i]+1 << "\n";
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
using namespace std;
void swap(int &a, int &b){
	int c=a;
	a=b;
	b=c;
}
vector<int> v;

int main(){
	int w, n;
	cin >> w >> n;
	int a[n], b[n];
	string s;
	for(int i=0; i<n; i++){
		cin >> s;
		a[i] = stoi(s);
		while(1){
			if(s[0]!=',') s.erase(s.begin(), s.begin()+1);
			else{
				s.erase(s.begin(), s.begin()+1);
				break;
			}
		}
		b[i] = stoi(s);
	}

	v.resize(w);
	for(int i=0; i<v.size(); i++) v[i]=i+1;
	for(int i=0; i<n; i++){
		swap(v[a[i]-1], v[b[i]-1]);
	}

	for(int i=0; i<n; i++) cout << v[i] << endl;

	return 0;
}

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

using namespace std;

int main(void){
  int x,y,a,b,n[31];
  char s;

  cin >> y >> x;
  for(int i=1; i<=y; i++)n[i]=i;

  for(int i=0; i<x; i++){
    cin >> a >> s >> b;
    swap(n[a],n[b]);
  }
  for(int i=1; i<=y; i++)cout << n[i] << endl;

  return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int w,n,b,c;
  cin>>w>>n;
  int a[w];
  for(int i=0;i<w;i++){
    a[i]=i+1;
  }
  for(int i=0;i<n;i++){
    scanf("%d,%d",&b,&c);
    int temp=a[b-1];
    a[b-1]=a[c-1];
    a[c-1]=temp;
  }
  for(int j=0;j<w;j++)cout<<a[j]<<endl;
}

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

using namespace std;
void lots(int len,int a,int b,int array[]){
    int buffer[5];
    for(int i = 0;i < len; i++){
        if(i == a-1){
            buffer[i] = array[b-1];
        }
        else if(i == b-1){
            buffer[i] = array[a-1];
        }
        else{
            buffer[i] = array[i];
        }
    }
    for(int i = 0; i < len; i++){
        array[i] = buffer[i];
    }

}

int main(){
    int len,duration,a,b;
    cin >> len;
    cin >> duration;
    int array[len];
    for(int i = 0; i < len; i++){
        array[i] = i+1;
    }
    for(int i = 0; i < duration; i++){
        scanf("%d,%d",&a,&b);
        lots(len,a,b,array);
    }
    for(int i = 0; i < len; i++){
        cout << array[i] << endl;
    }
}

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

int main(){
  vector<int> a;
  int w,n,s1,s2;
  char c;
  cin >> w >> n;
  for(int i=1;i<=w;i++)a.push_back(i);
  for(int i=0;i<n;i++){
	cin >> s1 >> c >> s2;
	swap(a[s1-1],a[s2-1]);
  }
  for(auto i:a)cout << i << endl;
  return 0;
}

C++: #include<stdio.h>

int main()
{
    int a,b,c,d;
    int x[30],y,z[30];
    scanf("%d%d",&a,&b);
    for(int i = 0; i < a; i++)
    {
        x[i]=i+1;
    }
    for(int i = 0; i < b; i++)
    {
        scanf("%d,%d",&c,&d);
        y = x[c-1];
        x[c-1] = x[d-1];
        x[d-1] = y;
    }
    for(int i = 0; i < a; i++)
    {
        printf("%d\n",x[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);
    // default
    for (int i = 0; i < vec.size(); ++i) {
      vec[i] = i + 1;
    }
    int n;
    cin >> n;
    cin.ignore(INT_MAX, '\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;
    }
  } // while loop out
  return 0;
}

C++: #include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int w, n;
    cin >> w >> n;
    VI a(w);
    REP(i,w) a[i] = i+1;
    while (n--){
        int x, y;
        scanf("%d,%d", &x, &y);
        swap(a[x-1], a[y-1]);
    }
    REP(i,w) cout << a[i] << endl;

    return 0;
}

C++: #include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
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 <vector>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <ctime>
#include <iterator>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;


int main()
{
    int w,n;
    cin>>w>>n;
    vector<int> act(w);
    for(int c=0;c<act.size();c++) act[c]=c+1;
    for(int c=0;c<n;c++)
    {
        string s;
        cin>>s;
        int a=0,b=0;
        int c2;
        for(c2=0;s[c2]!=',';c2++) {a*=10;a+=s[c2]-'0';}
        c2++;
        for(;c2<s.size();c2++) {b*=10;b+=s[c2]-'0';}

        swap(act[a-1],act[b-1]);
    }
    for(int c=0;c<w;c++) cout<<act[c]<<endl;
}

C++: 
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
#include<stdio.h>
using namespace std;
const int MAX = 100;
int main() {
	int W, N;
	int t[MAX];

	cin >> W >> N;
	for (int i = 0; i < W; i++) {
		t[i] = i;
	}
	for (int i = 0; i < N; i++) {
		int a, b;
		scanf("%d,%d", &a, &b); a--; b--;
		swap(t[a], t[b]);
	}
	for (int i = 0; i < W; i++) {
		printf("%d\n", t[i] + 1);
	}
	return 0;
}

C++: #include <iostream>

const int W_MAX = 30;
const int N_MAX = 30;

int w;
int n;
int a[N_MAX + 1];
int b[N_MAX + 1];
int out[W_MAX + 1];

void chenge(int *farst, int *second){
	int tmp;
	tmp = *farst;
	*farst = *second;
	*second = tmp;
}

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

	std::cin >> w;
	std::cin >> n;

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

	for(int i = 1; i <= n; i++){
		std::cin >> a[i] >> b[i];
		chenge(&out[a[i]], &out[b[i]]);
	}
	
	for(int i = 1; i <= w; i++){
		std::cout << out[i] << '\n';
	}

	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);
    // default
    for (int i = 0; i < vec.size(); ++i) {
      vec[i] = i + 1;
    }
    int n = 3;
    for (int i = 0; i < n; ++i) {

    }
    for (int i = 0; i < vec.size(); ++i) {
      cout << vec[i] << endl;
    }
  }
  return 0;
}