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 <array>
#include <vector>
#include <math.h>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <queue>

#define MAX 100005
#define ll long long int
using namespace std;

int main(void)
{
	string s; // input
	int n;
	int i, j;

	string an;
	int zero = 0; // zero?????´???

	vector <string> ans;
	queue <char> qu;

	char temp;
	int count = 0;
	char tempm; //mozi???????????????????´?




	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> an;

		for (j = 0; j < an.size(); j++) { //qu?????°?????????
			qu.push(an[j]);

		}



		
		while (qu.empty() == 0) {
			count = 0;
			tempm = 'n'; //?????????


			while (1) {
				temp = qu.front();
				if (temp != '0') {
					tempm = temp;
					count++;
					qu.pop();
				}
				else { //0?????£??????
					qu.pop();
					break;
				}


			}



			if (tempm == '1') { // 1?????¨???
				count = count % 5;

				switch (count) {
				case 1:
					s.push_back('.');
					break;
				case 2:
					s.push_back(',');
					break;
				case 3:
					s.push_back('!');
					break;
				case 4:
					s.push_back('?');
					break;
				case 0:
					s.push_back(' ');
					break;
				}
			}
			else if (tempm == '2') { // 2
				count = count % 3;
				switch (count) {
				case 1:
					s.push_back('a');
					break;
				case 2:
					s.push_back('b');
					break;
				case 0:
					s.push_back('c');
					break;

				}
			}
			else if (tempm == '3') { // 3
				count = count % 3;
				switch (count) {
				case 1:
					s.push_back('d');
					break;
				case 2:
					s.push_back('e');
					break;
				case 0:
					s.push_back('f');
					break;

				}
			}
			else if (tempm == '4') { // 4
				count = count % 3;
				switch (count) {
				case 1:
					s.push_back('g');
					break;
				case 2:
					s.push_back('h');
					break;
				case 0:
					s.push_back('i');
					break;

				}
			}
			else if (tempm == '5') { // 5
				count = count % 3;
				switch (count) {
				case 1:
					s.push_back('j');
					break;
				case 2:
					s.push_back('k');
					break;
				case 0:
					s.push_back('l');
					break;

				}
			}
			else if (tempm == '6') { // 6
				count = count % 3;
				switch (count) {
				case 1:
					s.push_back('m');
					break;
				case 2:
					s.push_back('n');
					break;
				case 0:
					s.push_back('o');
					break;

				}
			}
			else if (tempm == '7') { // 7
				count = count % 4;
				switch (count) {
				case 1:
					s.push_back('p');
					break;
				case 2:
					s.push_back('q');
					break;
				case 3:
					s.push_back('r');
					break;
				case 0:
					s.push_back('s');
					break;

				}
			}
			else if (tempm == '8') { // 8
				count = count % 3;
				switch (count) {
				case 1:
					s.push_back('t');
					break;
				case 2:
					s.push_back('u');
					break;
				case 0:
					s.push_back('v');
					break;

				}
			}
			else if (tempm == '9') { // 9
				count = count % 4;
				switch (count) {
				case 1:
					s.push_back('w');
					break;
				case 2:
					s.push_back('x');
					break;
				case 3:
					s.push_back('y');
					break;
				case 0:
					s.push_back('z');

				}
			}




		}

		ans.push_back(s);
		



		s.clear();
	}

	for (i = 0; i < ans.size(); i++) {
		cout << ans[i] << endl;
	}


	return (0);
}

C++: #include <iostream>
#include <string>
#include <stdio.h>
using namespace std;

char mes(char c){
    int n = c -'0';
    if(n==2)return 'a';
    else if(n==3)return 'd';
    else if(n==4)return 'g';
    else if(n==5)return 'j';
    else if(n==6)return 'm';
    else if(n==7)return 'p';
    else if(n==8)return 't';
    else return 'w';
}


int main(){
    long long int n;
    cin >> n;
    for(int i=0;i<n;i++){
        string str;
        cin >> str;
        int cou = 0;    
        for(int j=0;j<str.size();j++){
           if(str[j]=='0' && str[j-1]!='0' && j!=0){
                    cou--;
                    if(str[j-1]!='1'){
                        char a = mes(str[j-1]);
                        if(str[j-1]=='7'||str[j-1]=='9')printf("%c",a + (cou)%4);
                        else printf("%c",a+cou%3);
                    }else{
                       cou%=5;
                        if(!cou)cout << ".";
                        else if(cou==1)cout << ",";
                        else if(cou==2)cout << "!";
                        else if(cou==3)cout << "?";
                        else cout << " ";
                    }
                cou = 0;
           }else if(str[j]!='0'){
               cou++;
           }
        }
        cout << endl;
    }
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <cstdio>

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;(i)>=0;(i)--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

typedef long long ll;


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

int mod[10]={1,5,3,3,3,3,3,4,3,4};


int main(){
    
    int N;
    cin>>N;
    
    REP(i,N){
        string S;
        cin>>S;
        
        int cnt=0;
        string ans;
        
        REP(i,S.size()){
            if(S[i]!='0')cnt++;
            else{
                if(cnt!=0){
                    ans=ans+table[S[i-1]-'0'][(cnt-1)%mod[S[i-1]-'0']];
                    cnt=0;
                }
            }
        }
        
        cout<<ans<<endl;
        
    }
    
    return 0;
}

C++: #include <iostream>

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

int main(void) {
	int N;
	char str[1024];
	char out[128];

	char ntostr[][8] = {
		{},
		".,!? ",
		"abc",
		"def",
		"ghi",
		"jkl",
		"mno",
		"pqrs",
		"tuv",
		"wxyz"
	};

	std::cin >> N;
	for (int I = 0; I < N; I++) {
		std::cin >> str;
		int i = 0;
		int d = 0;
		int oi = 0;
		int cn = -1;
		while (str[i]) {
			int num = str[i] - '0';
			if (!num) {
				if (cn >= 0) {
					out[oi++] = ntostr[cn][d];
					cn = -1;
				}
			}
			else {
				if (cn != num) {
					cn = num;
					d = 0;
				}
				else {
					d++;
					if (!ntostr[cn][d]) d = 0;
				}
			}
			i++;
		}
		out[oi] = '\0';
		std::cout << out << '\n';
	}
	return 0;
}