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 <queue>
#include <string>
using namespace std;
int main(){
	string bottun[10] = { "0", ".,!?", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };
	queue<char> str;
	int n, i;
	cin >> n;
	while( n-- > 0 ){
		char s[1025];
		cin >> s;
		for( i = 0; s[i] != '\0'; i++ ){
			str.push(s[i]);
		}
		int t = 0, num;
		while( !str.empty() ){
			if( str.front() == '0' && num != 0 ){
				cout << bottun[num][(t-1)%bottun[num].length()];
				t = -1;
			}
			num = (int)(str.front() - '0');
			str.pop();
			t++;
		}
		cout << endl;
	}
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
	string strs[9]={{".,!?"},{"abc"},{"def"},{"ghi"},{"jkl"},{"mno"},{"pqrs"},{"tuv"},{"wxyz"}};
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string ans="",tmp;
		cin>>tmp;
		int a=0,b=0;//aがb回押された
		for(int j=0;j<tmp.size();j++){
			if(tmp[j]=='0'&&b>=1){
			ans+=strs[a-1][(b+strs[a-1].size()-1)%strs[a-1].size()];
			a=0,b=0;
			}
			if(tmp[j]=='0')continue;
			else {
				a=tmp[j]-'0';
				b++;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <queue>
#include <complex>

#define INF 100000000
#define EPS 1e-9

using namespace std;

typedef long long ll; 

#define MAX_N 31
#define MAX_M 501

int N;

string alpha[10];

vector<string> ans_list;

int main(){
  
  cin >> N;

  alpha[1] = ".,!? ";
  alpha[2] = "abc";
  alpha[3] = "def";
  alpha[4] = "ghi";
  alpha[5] = "jkl";
  alpha[6] = "mno";
  alpha[7] = "pqrs";
  alpha[8] = "tuv";
  alpha[9] = "wxyz";

  while(N > 0){
    N--;
    string str, ans;
    cin >> str;
    for(int i = 0; i < str.length(); i++){
      if(str[i] == '0')
	continue;
      int num = 0;
      for(int e = i+1; e < str.length(); e++){
	if(str[i] != str[e]){
	  num = e - i;
	  break;
	}
      }
      ans += alpha[str[i] - '0'][(num-1) % alpha[str[i] - '0'].length()];
      i += num;
    }
    ans_list.push_back(ans);
  }

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

  return 0;
  
}

C++: #include <iostream> // C++の入出力
#include <stdio.h> // C の入出力
#include <algorithm> // sort などのアルゴリズム
#include <string.h> // C の文字列用
#include <ctype.h> // C の文字種用
#include <string> // C++の文字列
#include <math.h>
#include <sstream>

using namespace std;
int main(void){
    int n;
    cin>>n;
    string out1=".,!? ";
    string out2="abc";
    string out3="def";
    string out4="ghi";
    string out5="jkl";
    string out6="mno";
    string out7="pqrs";
    string out8="tuv";
    string out9="wxyz";
    for(int s=0;s<n;s++){
        string in;
        cin>>in;
        int cnt=0;
        for(int i=0;i<in.length();i++){
            switch (in[i]-'0') {
                case 0:
                    switch (in[i-1]-'0') {
                        case 1:
                            cout<<out1[(cnt-1)%5];
                            break;
                        case 2:
                            cout<<out2[(cnt-1)%3];
                            break;
                        case 3:
                            cout<<out3[(cnt-1)%3];
                            break;
                        case 4:
                            cout<<out4[(cnt-1)%3];
                            break;
                        case 5:
                            cout<<out5[(cnt-1)%3];
                            break;
                        case 6:
                            cout<<out6[(cnt-1)%3];
                            break;
                        case 7:
                            cout<<out7[(cnt-1)%4];
                            break;
                        case 8:
                            cout<<out8[(cnt-1)%3];
                            break;
                        case 9:
                            cout<<out9[(cnt-1)%4];
                            break;
                        case 0:
                            break;
                    }
                    cnt=0;
                    break;
                default:
                    cnt++;
                    break;
            }
        }
        if(in=="0")cout<<"";
        else cout<<endl;
    }
    return 0;
}

C++: #include<iostream>
#include<string>

using namespace std;

#define NMAX 123456

int main(){

	string S[10]={"NULL",".,!?","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
	string in;
	int N;

	cin>>N;
	while(N--){
		cin>>in;
		int c;
		if(in[0]=='0') c=0;
		else c=1;
		for(int i=1;i<in.size();i++){
			if(in[i]=='0'){
				if(c!=0){
					cout<<S[in[i-1]-'0'][(c-1)%S[in[i-1]-'0'].size()];
					c=0;
				}
			}
			else c++;
		}
		cout<<endl;
	}

}