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>
using namespace std;
int main() {
  int w, n;
  cin >> w >> n;
  vector<int> vec;
  vec.resize(w);
  for (int i = 0; i < vec.size(); ++i) {
    vec[i] = i + 1;
  }
  int a, b;
  for (int i = 0; i < n; ++i) {
    scanf("%d,%d", &a, &b);
    a -= 1;
    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;
  }
  return 0;
}

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

int main()
{
	int w, n;
	cin >> w;
	int* num = new int[w];
	for (int i = 0; i < w; i++) {
		num[i] = i + 1;
	}
	for (cin >> n; n--;) {
		int a, b;
		char c;
		cin >> a >> c >> b;
		int tmp = num[a - 1];
		num[a - 1] = num[b - 1];
		num[b - 1] = tmp;
	}
	for (int i = 0; i < w; i++) {
		cout << num[i] << endl;
	}
	return 0;
}

C++: #include <iostream>

int main()
{
        int n, w;
        std::cin >> w >> n;
        
        int num[w], t, a, b;
        char c;

        for(t = 0; t < w ; ++t)
                num[t] = t + 1;

        while(n--)
        {
                std::cin >> a >> c >> b;
                t = num[a - 1];
                num[a - 1] = num[b - 1];
                num[b - 1] = t;
        }

        for(t = 0; t < w; ++t)
                std::cout << num[t] << std::endl;

        return 0;
}

C++: #include <stdio.h>

int main()
{
int p[31]={0};
int w,n,a,b;
char e;
int tmp;
tmp=0;
scanf("%d",&w);scanf("%d",&n);
for(int i=0;i<w;i++)
p[i]=i+1;
for(int i=0;i<n;i++)
{
scanf("%d,%d",&a,&b);
tmp=p[a-1];p[a-1]=p[b-1];p[b-1]=tmp;

}

for(int i=0;i<w;i++)
printf("%d\n",p[i]);

return 0;
}

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

using namespace std;

/*-------------------------------*/
#define FOR(i, a, b) for(int i = (a); i < (b); i++)  //a~(b - 1)?????§
#define print(i) cout << i << endl //?°??????????Python?????????
#define all(i) (i).begin(),(i).end() //??¨??????(sort??¨???)
#define mp make_pair //mp(OO, OO)??¨???:::pint??¨???

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> llv;
typedef vector<pint> vpint;
/*-------------------------------*/

int main(void)
{
  int w, n, a, b; cin >> w >> n;
  int x[35];
  FOR(i, 0, w + 1) x[i] = i;

  FOR(i, 0, n){
    scanf("%d,%d", &a, &b);
    swap(x[a], x[b]);
  } 

  FOR(i, 1, w + 1) cout << x[i] << endl;

  return 0;
}

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

int main()
{
    int n,w;
    int a,b;
    int yoko_1[100],yoko_2[100];
    int ans[100];
    char ch;
    
    cin>>w>>n;
    
    for (int i=0; i<n; i++) {
        cin>>a>>ch>>b;
        yoko_1[i]=a;
        yoko_2[i]=b;
    }
    
    int i=0,yoko=1,count=1;
    
    while (1) {
        if (yoko_1[i] == yoko) {
            yoko = yoko_2[i];
            i++;
        }
        else if(yoko_2[i] == yoko){
            yoko = yoko_1[i];
            i++;
        }
        else{
            i++;
        }
        if (w==i) {
            ans[yoko-1]=count;
            i=0;
            count++;
            yoko=count;
        }
        if(count>w){
            break;
        }
    }
    for (int i=0; i<w; i++) {
        cout<<ans[i]<<endl;
    }
    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);
    for (int i = 0; i < vec.size(); ++i) {
      vec[i] = i + 1;
    }
    int n;
    cin >> n;
    cin.clear();
    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;
    }
  }
  return 0;
}

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

C++: ude <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(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] << ' ';
	}

	std::cout << '/n';

	return 0;
}

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

int main()
{
	int w, n, wn[30];

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

C++: #include <iostream>

using namespace std;

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

    int lot[w + 1][n];
    fill(lot[0], lot[w + 1], 0);

    int a, b;
    char c;
    for (int i = 0; i < n; i++) {
        cin >> a >> c >> b;
        lot[a][i] = b;
        lot[b][i] = a;
    }

    int ans[w + 1];
    for (int i = 1; i <= w; i++) {
        int i_ = i;
        for (int j = 0; j < n; j++) {
            if (lot[i_][j] != 0) i_ = lot[i_][j];
        }
        ans[i_] = i;
    }
    for (int i = 1; i <= w; i++) {
        cout << ans[i] << endl;
    }
}

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

int main() {

  std::vector<int> v;
  int w;
  int n;
  int a, b;

  std::cin >> w;
  for(int i = 1; i <= w; ++i) {
    v.push_back(i);
  }

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

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

C++: #include <iostream>
#include <sstream>
#include <string>
int main()
{
  int w, n;
  std::cin >> w;
  std::cin >> n;
  int num[w + 1];
  for (int i = 1; i <= w; i++) {
    num[i] = i;
  }
  while (n--) {
    std::string line;
    std::cin >> line;
    int index = line.find(",");
    if (index != -1) line.replace(index, 1, " ");
    std::istringstream iss(line);
    int a, b, temp;
    iss >> a >> b;
    temp = num[a];
    num[a] = num[b];
    num[b] = temp;
  }
  for (int i = 1; i <= w; i++) {
    std::cout << num[i] << std::endl;
  }
  
  return 0;
}