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 <vector>
#include <utility>
using namespace std;

int main(){
	int w,n,a,b;
	char c;
	cin >> w >> n;
	vector<int> v;
	for(int i = 0; i < w+1; i++){
		v.push_back(i);
	} 
	
	for(int j = 0; j < n; j++){
		cin >> a >> c >> b;
		swap(v[a],v[b]);
	}
	
	for(int k = 1; k < w+1; k++){
		cout << v[k] << "\n";
	}
}

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

int main(){
	const int MAX_w = 30;
	int w, n, a, b, c, p;
	int lots[MAX_w + 1];
	string str;
	
	for(int i = 1; i <= MAX_w; i++){
		lots[i] = i;
	}
	
	cin >> w >> n;
	
	for(int i = 0; i < n; i++){
		a = 0; b = 0;
		cin >> str;
		
		p = 0;
		while(str[p] != ','){
			a = a * 10 + (str[p] - 48);
			p++;
		}
		p++;
		while(p < str.size()){
			b = b * 10 + (str[p] - 48);
			p++;
		}
		
		c = lots[a];
		lots[a] = lots[b];
		lots[b] = c;
	}
	
	for(int i = 1; i <= w; i++){
		printf("%d\n", lots[i]);
	}
	
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
 
typedef long long ll;
typedef pair<int, int> ii;
 
int main(){

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

C++: #include <iostream>

int main()
{
    int w, n;
    std::cin >> w >> n;

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

    for (int i = 0; i < n; ++i) {
        int a, b;
        char comma;
        std::cin >> a >> comma >> b;
        int tmp = state[a - 1]; state[a - 1] = state[b - 1]; state[b - 1] = tmp;
    }

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

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

using namespace std;

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

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

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

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

C++: #include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main()
{
int w,n,a,b,ans[30];
cin >> w >> n;
for(int i=0;i<w;i++)ans[i]=i+1;
for(int i=0;i<n;i++){
string ss;
cin >> ss;
swap(ans[(ss[0]-'0')-1],ans[(ss[2]-'0')-1]);
}
for(int i=0;i<w;i++)printf("%d\n",ans[i]);
return 0;
}

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

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int w, n;
  cin >> w >> n;
  int lots[30];
  for (int i = 0; i < w; i ++) {
    lots[i] = i;
  }
  for (int i = 0; i < n; i ++) {
    char c;
    int a, b;
    cin >> a >> c >> b;
    swap(lots[a - 1], lots[b - 1]);
  }
  for (int i = 0; i < w; i ++) {
    cout << lots[i] + 1 << 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[] = {1,2,3,4,5};
    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++: #define _CRT_SECURE_NO_WARNINGS
#define M_PI 3.14159265358979
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include<iomanip>
#include<vector>
#include<cmath>
#include <algorithm>

using namespace std;

int main(){

	int w, m[40], n, a, b, c;

	cin >> w;
	for (int i = 1; i <= w; i++)
	{
		m[i - 1] = i;
	}
	
	cin >> n;

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

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

C++: #include<iostream>
#include<stdio.h>
using namespace std;
main(){
	int w,n;
	cin>>w>>n;
	int a,b,ans[w+1];
	for(int i=0;i<=w;++i)ans[i]=i;
	for(int i=1;i<=n;++i){
		scanf("%d,%d",&a,&b);
		int tmp;
		tmp=ans[a];
		ans[a]=ans[b];
		ans[b]=tmp;
	}
	for(int i=1;i<=w;++i)cout<<ans[i]<<endl;
}

C++: 

#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>

using namespace std;

const int MAX_HORIZONTAL = 30;
const int MAX_VERTICAL = 30;

int main(){

	int VerticalLines;
	int HorizontalLines;
	int HorizonA[MAX_HORIZONTAL];
	int HorizonB[MAX_HORIZONTAL];
	int Results[MAX_VERTICAL];



	cin >> VerticalLines;
	cin >> HorizontalLines;
	for (int i = 0; i < HorizontalLines; ++i){ char c[32];  scanf_s("%d,%d", &HorizonA[i], &HorizonB[i]); }

	for (int i = 0; i < VerticalLines; ++i){ Results[i] = i + 1; }

	

	for (int i = 0; i < HorizontalLines; ++i){
		int Swap = Results[HorizonA[i] - 1];
		Results[HorizonA[i]-1] = Results[HorizonB[i] - 1];
		Results[HorizonB[i] - 1] = Swap;
	}

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





	return 0;
}

C++: #include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
using namespace std;

int main() {
  int w, n; cin >> w >> n;
  vector<pair<int, int>> vp(w);
  for (int i = 0; i < w; i++) {
      vp.at(i) = make_pair(i + 1, i + 1);
  }

  for (int i = 0; i < n; i++) {
    int a, b; char c; cin >> a >> c >> b;
    int tmp;
    for (int i = 0; i < w; i++) {
      if (vp.at(i).second == a) {
        vp.at(i).second = b;
        tmp = i;
      }
    }
    for (int i = 0; i < w; i++) {
      if (i == tmp) continue;
      if (vp.at(i).second == b) {
        vp.at(i).second = a;
      }
    }
  }

  for (int i = 0; i < w; i++) {
    swap(vp.at(i).first, vp.at(i).second);
  }

  sort(vp.begin(), vp.end());
  for (int i = 0; i < w; i++) {
    cout << vp.at(i).second << endl;;
  }
}

C++: #include <iostream>

using namespace std;

void change2(int* a, int* b) {
	int tmp;
	
	tmp = *a;
	*a  = *b;
	*b  = tmp;
}

int main(void) {
	int w, n;
	int a, b;
	int value[30];
	char buf[256];
	
	for (int i=0; i<30; i++) {
		value[i] = i+1;
	}
	
	fgets(buf, sizeof(buf), stdin);
	sscanf(buf, "%d", &w);
	fgets(buf, sizeof(buf), stdin);
	sscanf(buf, "%d", &n);
	
	for (int i=0; i<n; i++) {
		fgets(buf, sizeof(buf), stdin);
		sscanf(buf, "%d,%d", &a, &b);
		change2(&value[a-1], &value[b-1]);
	}
	
	for (int i=0; i<w; i++) {
		printf("%d\n", value[i]);
	}
	
	return 0;
}