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 <iostream>
using namespace std;
int main (){
	int w,N,d[30],c[30];
	cin>>w>>N;
	for(int j=1;j<=N;j++){
		d[j]=j;
		c[j]=d[j];
	}
	for(int i=0;i<w;i++){
		int a,b;
		cin>>a>>b;
		d[a]=d[b];
		d[b]=c[a];
		c[a]=d[a];
	}
	for(int k=0;k<N;k++){
	cout<<d[k]<<endl;
	}

	return 0;
}

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

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

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

int main(){
	int w, n, i, tmp, a, b;
	cin>>w;
	cin>>n;
	vector<int> vw(w);
	vector<vector<int> > vn(n, vector<int>(2));
	for(i=0;i<w;i++) vw[i] = i+1;
	for(i=0;i<n;i++){
		scanf("%2d,%2d",&a, &b);
		vn[i][0] = a-1;
		vn[i][1] = b-1;
		
		tmp = vw[(vn[i][0])];
		vw[(vn[i][0])] = vw[(vn[i][1])];
		vw[(vn[i][1])] = tmp;
	}
	for(i=0;i<w;i++) cout << vw[i] << endl;
	return 0;
}

C++: #include <iostream>
#include <string>
#include <stack>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <vector>

using namespace std;






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

}

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

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

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

int main() {
  int w, n, a, b, r[31], i, t;

  for (i = 1; i <= 30; i++) {
    r[i] = i;
  }

  cin >> w >> n;
  for (i = 0; i < n; i++) {
    scanf("%d,%d", &a, &b);
    t = r[a];
    r[a] = r[b];
    r[b] = t;
  }

  for (i = 1; i <= w; i++) {
    cout << r[i] << endl;
  }

  return 0;
}

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

typedef pair<int, int> P;
P line[MAX_N + 1];
int n, w;
char comma;
int result[MAX_W + 1];

void input()
{
	cin >> w >> n;
	for (int i = 1; i <= n; i++)
		cin >> line[i].first >> comma >> line[i].second;
}

void solve()
{
	int pos;
	for (int i = 1; i <= w; i++)
	{
		pos = i;
		for (int j = 1; j <= n; j++)
		{
			if (line[j].first == pos)
				pos = line[j].second;
			else if (line[j].second == pos)
				pos = line[j].first;
		}
		result[pos] = i;
	}
}

void print()
{
	for (int i = 1; i <= w; i++)
		cout << result[i] << endl;
}

int main()
{
	input();
	solve();
	print();
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    int w,n,str[30],fin[30],ans[31],add[31],now=0;
    char stri[7];
    cin>>w>>n;
    for(int i=0;i<n;i++){
        cin>>stri;
        if(stri[3]=='\0'){
            str[i]=stri[0]-'0';
            fin[i]=stri[2]-'0';
        }
        else if(stri[4]=='\0'&&stri[1]==','){
            str[i]=stri[0]-'0';
            fin[i]=(stri[2]-'0')*10+(stri[3]-'0');
        }
        else if(stri[4]=='\0'){
            str[i]=(stri[0]-'0')*10+(stri[1]-'0');
            fin[i]=stri[3]-'0';
        }
        else {
            str[i]=(stri[0]-'0')*10+(stri[1]-'0');
            fin[i]=(stri[3]-'0')*10+(stri[4]-'0');
        }
        add[i]=fin[i]-str[i];
    }
    for(int i=1;i<=w;i++){
        now=i;
        for(int j=0;j<n;j++){
            if(now==str[j])now+=add[j];
            else if(now==fin[j])now-=add[j];
        }
        ans[now]=i;
    }
    for(int i=1;i<=w;i++)cout<<ans[i]<<endl;
}

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

using namespace std;

int main(int argc, char *argv[]) {
  int ver, hor;

  cin >> ver;
  cin >> hor;
  int nums[ver];
  for (int i = 0; i < ver; i++)
    nums[i] = i+1;
  
  int tmp, a, b;
  for (int i = 0; i < hor; i++) {
    scanf("%d,%d", &a, &b);
    a--; b--;
    tmp = nums[a];
    nums[a] = nums[b];
    nums[b] = tmp;
  }

  for (int i = 0; i < ver; i++)
    cout << nums[i] << endl;
  return 0;
}

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

using namespace std;

int horizontalLine,verticalLine;
int A,B;
char UserInput[10];

int main()
{
        cin >> verticalLine;
        cin >> horizontalLine;
        if((verticalLine < 0 || horizontalLine < 0) || (verticalLine > 30 || horizontalLine > 30))
        {
            return 0;

        }

        int NumberExist[verticalLine];
        for(int y = 1; y <= verticalLine; y++)
        {
            NumberExist[y-1] = y;
        }

        for(int x = 1; x <= horizontalLine; x++)
        {
            cin >> UserInput;
            A = UserInput[0] - '0';
            B = UserInput[2] - '0';
            int TempVariable;
            TempVariable = NumberExist[A-1];
            NumberExist[A-1] = NumberExist[B-1];
            NumberExist[B-1] = TempVariable;

        }

        for(int z = 0; z < verticalLine; z++)
        {
            cout << NumberExist[z] << endl;
        }


}

C++: a = (1..gets.to_i).to_a
gets.to_i.times{
	x,y = gets.split(",").map(&:to_i)
	a[x-1], a[y-1] = a[y-1], a[x-1]
}
puts a

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

using namespace std;

void swap(int *var1, int *var2) {
  int tmp = *var1;
  *var1 = *var2;
  *var2 = tmp;
}

int main() {
  int w;
  int n;

  cin >> w;
  cin >> n;

  int vertical_line[w];
  for (int v_i = 0; v_i < w; v_i++)
    vertical_line[v_i] = v_i;

  for (int n_i = 0; n_i < n; n_i++) {
    int node1, node2;
    scanf("%d %d", &node1, &node2);
    swap(vertical_line+node1, vertical_line+node2);    
  }

  for (int v_i = 0; v_i < w; v_i++)
    cout << vertical_line[v_i] << endl;

  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

struct Line{
  int a,b;
};

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

  vector<Line> h_line(n);
  vector<int> ans(w);

  // input
  for(int i=0,a,b;i<n;++i){
    scanf("%d,%d", &a, &b);
    h_line[i].a = a;
    h_line[i].b = b;
  }

  // solve
  for(int i=1;i<=w;++i){
    int now = i;
    for(int j=0;j<n;++j){
      if(h_line[j].a == now)
        now = h_line[j].b;
      else if(h_line[j].b == now)
        now = h_line[j].a;
    }
    ans[now-1] = i;
  }

  // output answer
  for(int i=0;i<w;++i)
    cout<<ans[i]<<endl;

  return EXIT_SUCCESS;
}

C++: #include <bits/stdc++.h>
using namespace std;

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

C++: #include <iostream>
using namespace std;
 
int main(){
 
int w, n;
int num[30]={0};
int a, b;
 
for(int i=0; i<w; i++)
num[i]=i+1;
 
cin>>w;
cin>>n;
 
for(int i=0; i<n; i++){
 
cin>>a>>b;
 
int tmp=num[a];
num[a]=num[b];
num[b]=tmp;
 
 
}
 
 
for(int i=0; i<w; i++)
cout<<num[i]<<"\n";
 
return 0;
 
}