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>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<cstring>
#include<utility>
#include<set>
#include<stack>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX  999999
int main(){
    char ans[][10] = {
        {},
        {'.',',','!','?',' '},
        {'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'}
    };
    ll n; cin >> n;
    rep(i,n){
        string s(100000,0);
        cin >> s;
        int temp = 0;
        int counter =-1 ;
        for(int k = 0;k<(int)s.size();k++){
            int now = int(s[k]-48);
            if(k == 0){temp = now;counter++;}
            else if(now != 0){
                temp = now;counter++;}
            if(now == 0){
                if(temp  == 9 || temp == 7)
                    counter%=4;
                else if(temp != 1&& temp != 7 && temp!= 9)
                    counter%=3;
                else if(temp == 1)
                    counter %=5;
                cout << ans[temp][counter];
                temp = 0;counter =-1;;
            }
        }
        cout << endl;
    }
    return 0;
}

C++: #include <iostream>
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)

using namespace std;

int main()
{
  char keitai[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', '*'},
  };
  string s;
  int x , c;
  char p;
  int n;
  cin >> n;
  cin.ignore();
  REP(k, n){
    getline(cin, s);
    x = c = 0;
    p = '\0';
    REP(i, s.size()){
      int j;
      j = s[i] - '0';
      if(j){
        if(x == j){
          if(keitai[j][c + 1] == '*'){
            c = 0;
            p = keitai[j][c];
          }else{
            c++;
            p = keitai[j][c];
          }
        }else{
          c = 0;
          p = keitai[j][c];
        }
      }else{
        if(p != '\0')
          cout << p;
        p = '\0';
      }
      x = j;
    }
    cout << endl;
  }
}

C++: #include<iostream>
#include<cstring>
using namespace std;
int main(){
	int n,temp,sum,box[]={1,5,3,3,3,3,3,4,3,4};
	char s[1030];
	char tab[20][10]={" ",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
	cin>>n;
	while(n--){
		cin>>s;
		sum=0;
		for(int i=0;i<(int)strlen(s);i++){
			if(s[i]=='0'){
				if(sum!=0){
					cout<<tab[temp][(sum-1)%box[temp]];
				}
				sum=0;
			}
			else{
				temp=s[i]-'0';
				sum++;
			}
		}
		cout<<endl;
	}
	return 0;
}

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

using namespace std;
int main(){
  char m[9][5]={{'.',',','!','?',' '},
		{'a','b','c','1','1'},
		{'d','e','f','1','1'},
		{'g','h','i','1','1'},
		{'j','k','l','1','1'},
		{'m','n','o','1','1'},
		{'p','q','r','s','1'},
		{'t','u','v','1','1'},
		{'w','x','y','z','1'}};
  int a,count=0,c,d;
  char b[1025];
  cin>>a;
  for(int i=0;i<a;i++){
    scanf("%s",b);
    c=strlen(b);
    for(int j=0;j<c;j++){
      if(b[j]!='0')count++;
      else
	if(b[j-1]!=0){
	  d=(int)(b[j-1])-48;

	  if(d==1)
	    if(count%5!=0)
	      cout<<m[d-1][count%5-1];
	    else cout<<m[d-1][4];

	  else if(d==7 || d==9)
	    if(count%4!=0)
	      cout<<m[d-1][count%4-1];
	    else cout<<m[d-1][3];

	  else
	    if(count%3!=0)
	      cout<<m[d-1][count%3-1];
	    else cout<<m[d-1][2]; 
	  count=0;
	}
    }
    cout<<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,cash='a';
		int count = 0,idx=0;
		int n = 0;
		while(n <str.size()){
			cur = str[n];

			if(cur == '0'){
					if (idx == 0) count = 0;
					else {
						out +=list[idx][count%=list[idx].size()];
						count =0;
						idx=0;
					}
			}
			else if(cur ==cash){
				count +=1;
			}
			else{
				idx= (int)(cur - '0');
			}
			cash = cur;
			n++;
		}//?????????????????°???????????????
		cout << out << endl;
		out ="";
	}
		return 0;
}

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

int main() {
	int a;
	cin >> a;
	for (int b = 0; b < a; b++) {
		string c;
		cin >> c;
		string s = "";
		string p = "";
		for (char d : c) {
			if (d == '0') {
				if (p.length()) {
					if (p[0] == '1') {
						switch (p.length()%5) {
						case 1:s += '.'; break;
						case 2:s += ','; break;
						case 3:s += '!'; break;
						case 4:s += '?'; break;
						case 0:s += ' '; break;
						}
					}
					else if (p[0] == '9') {
						switch (p.length() % 4) {
						case 0:s += 'z'; break;
						case 1:s += 'w'; break;
						case 2:s += 'x'; break;
						case 3:s += 'y'; break;
						}
					}
					else if (p[0] == '7') {
						switch (p.length() % 4) {
						case 0:s += 's'; break;
						case 1:s += 'p'; break;
						case 2:s += 'q'; break;
						case 3:s += 'r'; break;
						}
					}
					else if (p[0] == '8') {
						switch (p.length() % 3) {
						case 0:s += 'v'; break;
						case 1:s += 't'; break;
						case 2:s += 'u'; break;
						}
					}
					else {
						int u=((p[0] - 48) * 3 + p.length()%3 + 90);
						if (p.length() % 3 == 0)u += 3;
						s += u;
					}
				}
				p = "";
			}
			else p += d;
		}
		cout << s << endl;
	}
}