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;

int    nextInt()    { int d;      cin >> d;   return d;   }
string nextString() { string str; cin >> str; return str; }

string solve(string input) {
  string ret;

  char keys[][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 key_size[] = {
    -1, 5, 3, 3, 3, 3, 3, 4, 3, 4
  };
  
  char next;
  int idx = 0;
  for (int i = 0; i < input.size(); i++) {
    char c = input[i];
    if (c == '0') {
      ret += next;
      next = '\0';
      idx = 0;
    } else {
      next = keys[c - '0'][idx];
      idx = (idx + 1) % key_size[c - '0'];
    }
  }
  
  return ret;
}

int main() {
  int n = nextInt();
  for (int i = 0; i < n; i++) {
    string input = nextString();
    cout << solve(input) << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>

using namespace std;

#define INF 999999999

int main(){
	int N, i, j, pr, b, n, no[10]={1,5,3,3,3,3,3,4,3,4};
	string s;
	vector<string> c(10);
	c[0] = "a";
	c[1] = ".,!? ";
	c[2] = "abc";
	c[3] = "def";
	c[4] = "ghi";
	c[5] = "jkl";
	c[6] = "mno";
	c[7] = "pqrs";
	c[8] = "tuv";
	c[9] = "wxyz";
	
	cin >> N;
	for(i=0;i<N;i++){
		cin >> s;
		pr = 0;
		n = 0;
		//cout << s.size();
		for(j=0;j<s.size();j++){
			b = s[j] - '0';
			//cout << b;
			if(pr == b){
				n++;
			}
			else if(b==0){
				//cout << pr << n%no[pr] << endl;
				cout << c[pr][n%no[pr]];
			}
			else {
				n=0;
			}
			pr = b;
		}
		cout << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	char a[9][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 n,b=0,c=0,d=0;
	string s;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;b=d=c=0;
		char ss[100];
			for(int j=0;j<s.size();j++){
				if(s[j]=='0'&&c>0){
					if(s[j-1]=='1')d=(c-1)%5;
					else if(s[j-1]=='6'||s[j-1]=='8')d=(c-1)%4;
					else d=(c-1)%3;
					cout<<a[(int)(s[j-1]-'0')-1][d];
				c=0;
				}
				else c++;
				}
				cout<<endl;
	}
	return 0;
}

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

using namespace std;

int main(){
	int n; cin >> n;
	vector<string> button(10);
	button[1] = ".,!? ";
	button[2] = "abc";
	button[3] = "def";
	button[4] = "ghi";
	button[5] = "jkl";
	button[6] = "mno";
	button[7] = "pqrs";
	button[8] = "tuv";
	button[9] = "wxyz";
	for(int i = 0; i < n; ++i){
		string str; cin >> str;
		int acc = -1;
		int pre = 0;
		for(int j = 0; j < str.size(); ++j){
			if(str[j] == '0'){
				if(pre == 0) continue;
				int s = button[pre].size();
				char out = button[pre][acc % s];
				cout << out;
				acc = -1;
			}
			else{
				if(acc == -1){
					acc = 0;
					pre = str[j] - '0';
				}
				else{
					acc ++;
				}
			}

		}
		cout << endl;
	}
	return 0;
}

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

map<char, string> convert_table;

void init() {
    convert_table['1'] = ".,!? ";
    convert_table['2'] = "abc";
    convert_table['3'] = "def";
    convert_table['4'] = "ghi";
    convert_table['5'] = "jkl";
    convert_table['6'] = "mno";
    convert_table['7'] = "pqrs";
    convert_table['8'] = "tuv";
    convert_table['9'] = "wxyz";
}

char convert(char c, int n) {
    n = (n-1) % convert_table[c].size();
    return convert_table[c][n];
}

int main() {
    init();
    int n;
    cin >> n; getchar();
    for (int i = 0; i < n; i++) {
        string s, t;
        getline(cin, s);
        char prev = s[0];
        int count = 1;
        for (int j = 1; j < s.size(); j++) {
            if (s[j] == prev) {
                count++;
            } else if (s[j] == '0') {
                if (prev == '0') {
                    continue;
                } else {
                    t.push_back(convert(prev, count));
                    prev = s[j];
                    count = 0;
                } 
            } else {
                prev = s[j];
                count = 1;
            }
        }
        cout << t << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		int ans=0;
		int j=0;
		while(j<s.size()){
			int cnt=0;
			int t=0;
			while(s[j+t+1]!='0'){
				if(s[j]=='0')break;
				t++;
			}
			if(s[j]=='1'){
				if((t+1)%5==1){
					cout<<".";
				}
				if((t+1)%5==2){
					cout<<",";
				}
				if((t+1)%5==3){
					cout<<"!";
				}
				if((t+1)%5==4){
					cout<<"?";
				}
				if((t+1)%5==0){
					cout<<" ";
				}
			}
			if(s[j]=='2'){
				if((t+1)%3==1){
					cout<<"a";
				}
				if((t+1)%3==2){
					cout<<"b";
				}
				if((t+1)%3==0){
					cout<<"c";
				}
			}
			if(s[j]=='3'){
				if((t+1)%3==1){
					cout<<"d";
				}
				if((t+1)%3==2){
					cout<<"e";
				}
				if((t+1)%3==0){
					cout<<"f";
				}

			}
			if(s[j]=='4'){
				if((t+1)%3==1){
					cout<<"g";
				}
				if((t+1)%3==2){
					cout<<"h";
				}
				if((t+1)%3==0){
					cout<<"i";
				}
			}
			if(s[j]=='5'){
				if((t+1)%3==1){
					cout<<"j";
				}
				if((t+1)%3==2){
					cout<<"k";
				}
				if((t+1)%3==0){
					cout<<"l";
				}
			}
			if(s[j]=='6'){
				if((t+1)%3==1){
					cout<<"m";
				}
				if((t+1)%3==2){
					cout<<"n";
				}
				if((t+1)%3==0){
					cout<<"o";
				}
			}
			if(s[j]=='7'){
				if((t+1)%4==1){
					cout<<"p";
				}
				if((t+1)%4==2){
					cout<<"q";
				}
				if((t+1)%4==3){
					cout<<"r";
				}
				if((t+1)%4==0){
					cout<<"s";
				}
			}
			if(s[j]=='8'){
				if((t+1)%3==1){
					cout<<"t";
				}
				if((t+1)%3==2){
					cout<<"u";
				}
				if((t+1)%3==0){
					cout<<"v";
				}
			}
			if(s[j]=='9'){
				if((t+1)%4==1){
					cout<<"w";
				}
				if((t+1)%4==2){
					cout<<"x";
				}
				if((t+1)%4==3){
					cout<<"y";
				}
				if((t+1)%4==0){
					cout<<"z";
				}
			}
			j+=t+1;
			
		}
		cout<<endl;
	}
	return 0;
}