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'}
    };
    int n; cin >> n;
    rep(i,n){
        string s(100000,0);
        cin >> s;
        int temp = 0;
        int counter =-1 ;
        for(int k = 0;k<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;
    }
}

C++: #include <iostream>
#include <string>
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;
	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;
	}

	return 0;
}

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

using namespace std;

char num1[5]={'.', ',', '!', '?', ' '};
char num2[]="abc", num3[]="def", num4[]="ghi", num5[]="jkl", num6[]="mno", num7[]="pqrs", num8[]="tuv", num9[]="wxyz";

char func(int x, int y);

int main()
{
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		int c1, c2=-1, c3=0;
		char c;
		c1 = getchar();
		while(1){
			c1 = getchar();
			if(c1 == '\n'){
				cout << endl;
				c3 = 0;
				break;
			} else if(c1 == '0'){
				if(c2 != -1){
					c = func(c2, c3);
					cout << c;
					c3 = 0;
				}
			} else {
				if(c1 == c2) c3++;
				else {
					c1 = c1 - '0';
					c2 = c1;
					c3++;
				}
			}
		}
	}
	return 0;
}

char func(int x, int y)
{
	int z;
	if(x == 1) return num1[(y-1)%5];
	else if(x == 2) return num2[(y-1)%3];
	else if(x == 3) return num3[(y-1)%3];
	else if(x == 4) return num4[(y-1)%3];
	else if(x == 5) return num5[(y-1)%3];
	else if(x == 6) return num6[(y-1)%3];
	else if(x == 7) return num7[(y-1)%4];
	else if(x == 8) return num8[(y-1)%3];
	else return num9[(y-1)%4];
}

C++: #include <bits/stdc++.h>
using namespace std;

char trans(char num, int i){
    if(num == '1'){
        if(i % 4 == 1) return '.';
        else if(i % 4 == 2) return ',';
        else if(i % 4 == 3) return '!';
        else if(i % 4 == 0) return '?';
    }
    if(num == '2'){
        if(i % 3 == 1) return 'a';
        else if(i % 3 == 2) return 'b';
        else if(i % 3 == 0) return 'c';
    }
    if(num == '3'){
        if(i % 3 == 1) return 'd';
        else if(i % 3 == 2) return 'e';
        else if(i % 3 == 0) return 'f';
    }
    if(num == '4'){
        if(i % 3 == 1) return 'g';
        else if(i % 3 == 2) return 'h';
        else if(i % 3 == 0) return 'i';
    }
    if(num == '5'){
        if(i % 3 == 1) return 'j';
        else if(i % 3 == 2) return 'k';
        else if(i % 3 == 0) return 'l';
    }
    if(num == '6'){
        if(i % 3 == 1) return 'm';
        else if(i % 3 == 2) return 'n';
        else if(i % 3 == 0) return 'o';
    }
    if(num == '7'){
        if(i % 4 == 1) return 'p';
        else if(i % 4 == 2) return 'q';
        else if(i % 4 == 3) return 'r';
        else if(i % 4 == 0) return 's';
    }
    if(num == '8'){
        if(i % 3 == 1) return 't';
        else if(i % 3 == 2) return 'u';
        else if(i % 3 == 0) return 'v';
    }
    if(num == '9'){
        if(i % 4 == 1) return 'w';
        else if(i % 4 == 2) return 'x';
        else if(i % 4 == 3) return 'y';
        else if(i % 4 == 0) return 'z';
    }
    return '0';
}

int main(){
    int n;
    cin >> n;
    string s;

    for(int i = 0; i < n; i++){
        cin >> s;
        for(int j = 0; j < (int)s.size(); j++){
            int cnt = 0;
            if(s[j] == '0'){
                if(s[j-1] != '0'){
                    int k = j - 1;
                    cnt = 1;
                    while(s[k] == s[k - 1]){
                        cnt++;
                        k--;
                    }
                }
                cout << trans(s[j-1], cnt);
            }
        }
        cout << endl;
    }

    return 0;
}