Go: package main

import (
	"bytes"
	"fmt"
)

//Ktai has a keyboard and a state.
type Ktai struct {
	keyboard KeyBoard
	textBuf  *bytes.Buffer
}

// KeyBoard is type of a map.
type KeyBoard map[rune]string

// KEYBOARD that Ktai has
var KEYBOARD = KeyBoard{
	'0': "",
	'1': ".,!? ",
	'2': "abc",
	'3': "def",
	'4': "ghi",
	'5': "jkl",
	'6': "mno",
	'7': "pqrs",
	'8': "tuv",
	'9': "wxyz",
}

func main() {
	var N int
	fmt.Scanf("%d", &N)
	ktai := &Ktai{
		KEYBOARD, &bytes.Buffer{},
	}
	for i := 0; i < N; i++ {
		var numstr string
		fmt.Scanf("%s", &numstr)
		ktai.feed(numstr)
		ktai.print()
	}
}

func (ktai *Ktai) feed(str string) {
	var char *byte
	for _, v := range str {
		if v == '0' {
			if char != nil {
				ktai.textBuf.WriteByte(*char)
				char = nil
			}
			continue
		} else {
			runestring := ktai.keyboard[v]
			idx := ktai.indexOf(char, runestring)
			next := (idx + 1) % len(runestring)
			c := runestring[next]
			char = &c
		}
	}
}

func (ktai *Ktai) indexOf(ch *byte, str string) int {
	if ch == nil {
		return -1
	}
	r := rune(*ch)
	idx := -1
	for i, v := range str {
		if r == v {
			idx = i
			break
		}
	}
	return idx
}

func (ktai *Ktai) print() {
	fmt.Println(ktai.textBuf.String())
	ktai.textBuf.Reset()
}

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

string cell[9] = {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};

int main(){
    int n;
    scanf("%d\n", &n);

    for(int i = 0; i < n; i++){
        string s;
        getline(cin,s);
        int len = s.length();
        for(int j = 0; j < len; j++){
            int cnt = 0;
            char x = s[j];
            if(x == '0')    continue;
            while(j < len && s[j] == x)    j++, cnt++;
            int tmplen = cell[x-'1'].length();
            cout << cell[x-'1'][(cnt-1+tmplen)%(tmplen)];
        }
        cout << endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
  int n, count = 0;
  string input;
  map<char, string> map;

  map['1'] = ".,!? ";
  map['2'] = "abc";
  map['3'] = "def";
  map['4'] = "ghi";
  map['5'] = "jkl";
  map['6'] = "mno";
  map['7'] = "pqrs";
  map['8'] = "tuv";
  map['9'] = "wxyz";

  cin >> n;
  int j = 0, i;
  for(i = 0 ; i < n ; i++){
    cin >> input;
    for(j = 0 ; input[j] == '0' && j < (int)input.length() ; j++);

    for( ; j <  (int)input.length() ; j++){
      if(input[j] == '0'){
	if(input[j-1] == '0')continue;
	string hoge = map[input[j-1]];
	cout << hoge[(count-1)%(hoge.length())];
	count = 0;
      }else{
	count++;
      }
    }
    cout << '\n';
      } 
  
}

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

int compare(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}

int main(void) {
	int n;
	int score[1024];

	while (true) {
		std::cin >> n;
		if (!n) break;

		for (int i = 0; i < n; i++) std::cin >> score[i];

		qsort(score, n, sizeof(int), compare);
		double sum = 0;
		for (int i = 1; i < n - 1; i++) sum += score[i];
		int ave = int(sum / (n-2));
		std::cout << ave << '\n';
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

vector<string> button = {
    "kakutei", " .,!?", "cab",  "fde", "igh",
    "ljk",     "omn",   "spqr", "vtu", "zwxy",
};

void solve() {
    string s, ans = "";
    cin >> s;
    vector<int> ncnt(10, 0);
    for(int i = 0; i < s.size(); i++) {
        int now = s[i] - '0';
        if(now == 0) {
            if(i == 0) {
                continue;
            }
            int pre = s[i - 1] - '0';
            if(pre == 0) {
                continue;
            }
            ans += button[pre][ncnt[pre]];
            ncnt.assign(10, 0);
        } else {
            ncnt[now] = (ncnt[now] + 1) % (int)button[now].size();
        }
    }
    cout << ans << endl;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t;
    cin >> t;
    while(t--) {
        solve();
    }
}

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

using namespace std;

string solve(string s) {
    int num = -1;
    int count = 0;
    string message = "";
    string chars[] = {
        ".,!? ", "abc", "def",
        "ghi", "jkl", "mno",
        "pqrs", "tuv", "wxyz"
    };
    for (int i = 0; i < (int)s.length(); ++i) {
        if (s[i] == '0') {
            if (num > 0) {
                int len = chars[num - 1].length();
                message += chars[num - 1][(count + len - 1) % len];
            }
            count = 0;
            num = -1;
        } else {
            ++count;
            num = s[i] - '0';
        }
    }
    return message;
}

int main() {
    int n;
    string s;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> s;
        cout << solve(s) << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
	string list[] = {
		" ",".,!? ","abc","def"
		,"ghi","jkl","mno"
		,"pqrs","tuv","wxyz"
	};
	string str,out;
	int times;
	cin >> times;
	for(int i =0 ;i<times;i++){
		cin >> str;
		char cur='1',cash='a';
		int count = 0,idx;
		int n = 0;
		while(n <str.size()){
			cur = str[n];
			if(cur = 0){
							out +=list[idx][count%=list[idx].size()];
			}
			else if(cur ==cash){
				count +=1;
			}
			else{
				idx= (int)(cur - '0');
			}
			n++;
		}//?????????????????°???????????????
		cout << out << endl;
		out ="";
	}
		return 0;
}

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

typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define DECIM8  fixed<<setprecision(8) 
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
int main(void)
{
  string lib[10]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
  int t;
  cin >> t;
  for(;t--;){
    string input;
    cin >> input;
    char last='0';
    int ren=0;
    REP(i,SZ(input)){
      if(input[i]==last) ++ren;
      else{
	if(last-'0')
	  cout << lib[last-'0'][ren%SZ(lib[last-'0'])];
	ren=0;
      }
      last=input[i];
    }
    cout << endl;
  }
  return 0;
}

C++: //#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <cstring>
#include <climits>
#include <queue>
#include <algorithm>
#include <utility>
#define INF INT_MAX / 2
using namespace std;

typedef pair<int, int> P;
typedef long long ll;

int main(void) {
	
	string c[] = {".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};

	int t;
	cin >> t;
	for(int i=0;i<t;i++){
		int cnt = 0;
		string s;
		cin >> s;
		for(int i=0;i<s.size();i++){
			if(s[i] == '0'){
				if(cnt == 0)continue;
				int n = s[i-1]-'1';
				cout << c[n][(cnt-1)%(c[n].size())];
				cnt = 0;
			}else cnt++;
		}
		cout << endl;
	}

}

// command shift d duplicate
// command ctrl 上下
// command D
// command caps G → '' ""
// vector<vector<int>> a(N,vector<int>(M,-1));