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<cstdio>
#include<iostream>
#include<vector>
#include<string>
using namespace std;

int main() {
	int n;
	vector<vector<char>>boad(10);
	boad[1] = { '.',',','!','?',' ' };
	char c = 'a';
	for (int i = 2; i < 10; ++i) {
		if (i != 7 && i != 9) {
			for (int j = 0; j < 3; ++j) {
				boad[i].push_back(c++);
			}
		}
		else for (int j = 0; j < 4; ++j)boad[i].push_back(c++);
	}
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		char b,pre='0';
		int count = 1;
		int sup = s.length();
		for (int l = 0; l < sup; ++l) {
			b = s[l];
			if (pre != b) {
				int num = pre - '0';
				if (num) printf("%c", boad[num][(count - 1) % boad[num].size()]);
				count = 1;
				pre = b;
			}
			else count++;
		}
		printf("\n");
	}
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<stdlib.h>

using namespace std;

vector<string> ans;
string bot[10] = {"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
int main(){
	int n;
	cin >> n;
	for(int i = 0;i < n;i++){
		string mess;
		string code;
		cin >> code;
		int count = 0;
		for(int j = 0;j < code.size();j++){
			if(code[j] == '0'){
				if(j == 0 || count == 0) continue;
				int num = 1;
				for(int k = 1;k <= 9;k++){
					if(('0' + k) == code[j-1]){num = k; break;}
				}
				int roop = bot[num].size();
				mess += bot[num][(count - 1)% roop];
				count = 0;
			}else{
				count++;
			}
		}
		ans.push_back(mess);
	}
	
	for(int i = 0;i < n;i++){
		cout << ans[i] << endl;
	}
	return 0;
}

C++: #include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define INF 1000000000
#define rep(i,a,b) for (int i=(a);i<(b);i++)
#define rev(i,a,b) for (int i=(a)-1;i>=b;i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef queue<int> qi;
typedef vector<int> vi;
typedef vector<string> vs;
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };

char c[9][6] = {
	{'.', ',', '!', '?', ' '},
	{'a', 'b', 'c'},
	{'d', 'e', 'f'},
	{'g', 'h', 'i'},
	{'j', 'k', 'l'},
	{'m', 'n', 'o'},
	{'p', 'q', 'r', 's'},
	{'t', 'u', 'v'},
	{'w', 'x', 'y', 'z'}
};

int main() {
	int n;
	cin >> n;
	rep(i,0,n) {
		string s;
		cin >> s;
		int num = 0;
		string ans = "";
		rep(j,0,s.size()) {
			if(s[j] != '0') num++;
			else {
				if(num == 0) continue;
				char tmp = s[j-1];
				int b = atoi(&tmp)-1;
				if(b == 0) ans += c[b][(num-1)%5];
				else if(b == 6 || b == 8) ans += c[b][(num-1)%4];
				else ans += c[b][(num-1)%3];
				num = 0;
			}
		}
		cout << ans << endl;

	}

	return 0;
}

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

int main()
{
	int n;
	cin>>n;
	vector<string> D(10);
	D[0]="";
	D[1]=".,!? ";
	D[2]="abc";
	D[3]="def";
	D[4]="ghi";
	D[5]="jkl";
	D[6]="mno";
	D[7]="pqrs";
	D[8]="tuv";
	D[9]="wxyz";

	for(int i=0;i<n;i++){
		string s;
		cin>>s;

		int pos=0;
		int now=-1;
		int count=0;
		while(pos<s.size()){
			if(s[pos]=='0'){
				if(now<0){pos++;continue;}
				count%=D[now].size();
				cout<<D[now][count];
				count=0;
				pos++;
				now=-1;
			}
			else{
				if(now<0){
					now=s[pos]-'0';
					count=0;
					
				}
				else count++;
				pos++;
			}
		}
		cout<<endl;
	}
	return 0;
}

C++: null

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long int lli;

string charset[10][5] = {
	{},
	{".", ",", "!", "?", " "},
	{"a", "b", "c"},
	{"d", "e", "f"},
	{"g", "h", "i"},
	{"j", "k", "l"},
	{"m", "n", "o"},
	{"p", "q", "r", "s"},
	{"t", "u", "v"},
	{"w", "x", "y", "z"}
};
int loop[10] = {0, 5, 3, 3, 3, 3, 3, 4, 3, 4};

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

	int N;
	cin >> N;
	vector<string> ansvec;
	for (int n = 0; n < N; n++){
		string s;
		cin >> s;

		int i = 0;
		int push = -1;
		string ans = "";
		while (i < s.length()){
			int num = stoi(s.substr(i, 1));
			if (num != 0){
				int thisnum = num;
				while (num != 0){
					push++;
					i++;
					num = stoi(s.substr(i, 1));
				}
				ans += charset[thisnum][push % loop[thisnum]];
				push = -1;
			}
			i++;
		}
		cout << ans << endl;
		//ansvec.push_back(ans);
	}
/*
	for (auto it = ansvec.begin(); it != ansvec.end(); it++){
		cout << *it << endl;
	}*/
	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
 
string keitai[]{".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
int main(){
	int n;cin>>n;
    string s;
    rep(j,n){
		cin>>s;
        int cnt=0;
        string ans;
        rep(i,s.size()){
            if(s[i]=='0'){
                if(cnt)ans+=keitai[s[i-1]-'1'][(cnt-1)%keitai[s[i-1]-'1'].size()];
                cnt=0;
            }
            else cnt++;
        }
        if(ans!="")cout<<ans<<endl;
    }
}

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

int main(){
  string s;
  int N;
  char bot[10][20]={"0",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"}; 

  int count=0,flag=0;
  while(1){
  cin>>N;
  if(N==0)break;
  for(int i=0;i<N;i++){
    count=0;
    cin>>s;
    for(int j=0;j<(int)s.size();j++){
      if(s[j]!='0'&&flag==0){
	flag=s[j]-'0';
      }else if(flag!=0&&s[j]!='0'){
	count++;
      }else if(s[j]=='0'&&flag!=0){
	if(count<=strlen(bot[flag]))cout<<bot[flag][count];
	else{
	  while(count>strlen(bot[flag])){
	    count=count-strlen(bot[flag]);
	  }
	  cout<<bot[flag][count];
	}
	count=0;
	flag=0;
      }
    }
    cout<<endl;
  }
  }
  return 0;
}