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 <vector>
#include <string>
using namespace std;

int main(){
  vector<vector<char> > v;
  vector<char> mv;

  mv.push_back(' ');mv.push_back('.');mv.push_back(',');mv.push_back('!');mv.push_back('?');
  v.push_back(mv);
  mv.clear();

  mv.push_back('c');mv.push_back('a');mv.push_back('b');
  v.push_back(mv);
  mv.clear();

  mv.push_back('f');mv.push_back('d');mv.push_back('e');
  v.push_back(mv);
  mv.clear();

  mv.push_back('i');mv.push_back('g');mv.push_back('h');
  v.push_back(mv);
  mv.clear();

  mv.push_back('l');mv.push_back('j');mv.push_back('k');
  v.push_back(mv);
  mv.clear();

  mv.push_back('o');mv.push_back('m');mv.push_back('n');
  v.push_back(mv);
  mv.clear();

  mv.push_back('s');mv.push_back('p');mv.push_back('q');mv.push_back('r');
  v.push_back(mv);
  mv.clear();

  mv.push_back('v');mv.push_back('t');mv.push_back('u');
  v.push_back(mv);
  mv.clear();

  mv.push_back('z');mv.push_back('w');mv.push_back('x');mv.push_back('y');
  v.push_back(mv);
  mv.clear();

  string s;
  int a,i,cou,n,cou2;
  while(cin >> s){ // 入力
    a=s.size();
    //cout <<a<< ' ';//////////////////
    i=0;
    cou2=0;
    while(i<a){//改行まで
      cou=0;
      n=0;
      while(s[i]!='0'&&i<a){//０まで
	n=s[i]-'0';
	i++;
	cou++;
      }
      i++;
      //cout <<n<< cou<< ' ';/////////////////
      if(cou!=0&&i<=a){
	if(n==8||n==2||n==3||n==4||n==5||n==6)cou=cou%3;
	else if(n==7||n==9)cou=cou%4;
	else if(n==1)cou=cou%5;

	cout<<v[n-1][cou];
	cou2++;
      }
    }
    if(cou2!=0)cout<<endl;
  }
  return 0;
}

C++: #include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    int L;
    cin >> L;

    vector<vector<char>> table(10, vector<char>());
    table[1].push_back('.');
    table[1].push_back(',');
    table[1].push_back('!');
    table[1].push_back('?');
    table[1].push_back(' ');
    for (int i = 2; i <= 7; i++) {
        for (int j = 0; j < 3; j++) {
            table[i].push_back('a' + (i - 2) * 3 + j);
        }
    }
    table[7].push_back('s');
    table[8].push_back('t');
    table[8].push_back('u');
    table[8].push_back('v');
    table[9].push_back('w');
    table[9].push_back('x');
    table[9].push_back('y');
    table[9].push_back('z');


    for (int i = 0; i < L; i++) {
        string s;
        cin >> s;

        int kind = -1, num = -1;
        for (char c : s) {
            if (c == '0') {
                if (kind != -1) {
                    printf("%c", table[kind][num % table[kind].size()]);
                }
                kind = -1;
                num = -1;
            } else {
                kind = c - '0';
                num++;
            }
        }
        cout << endl;
    }
}

C++: #include <cstdio>
#include <iostream>
#include <string>
using namespace std;
string s[9]={".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		string ss;
		cin >> ss;
		int cnt=0,now;
		for(int j=0;j<ss.size();j++){
			if(ss[j]-'0'==0){
				if(cnt==0) continue;
				printf("%c",s[now-1][(cnt-1)%s[now-1].size()]);
				cnt=0;
				continue;
			}
			cnt++;
			now=ss[j]-'0';
		}
		printf("\n"); 
	}
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int m;
	cin>>m;
	while(m-->0){
		string s;
		string ans;
		pair<int,int> p;
		cin>>s;
		p.first=0;
		p.second=0;

		for(unsigned int i=0; i<s.length();++i){
			if(s[i]=='0'){
				if(p.second<=0)continue;
				switch(p.first){
					case 1:
						ans+=".,!? "[(p.second-1)%5];
						break;
					case 2:
						ans+="abc"[(p.second-1)%3];
						break;
					case 3:
						ans+="def"[(p.second-1)%3];
						break;
					case 4:
						ans+="ghi"[(p.second-1)%3];
						break;
					case 5:
						ans+="jkl"[(p.second-1)%3];
						break;
					case 6:
						ans+="mno"[(p.second-1)%3];
						break;
					case 7:
						ans+="pqrs"[(p.second-1)%4];
						break;
					case 8:
						ans+="tuv"[(p.second-1)%3];
						break;
					case 9:
						ans+="wxyz"[(p.second-1)%4];
						break;
				}
				p.first=-1;
				p.second=-1;
			}
			p.first=s[i]-'0';
			p.second++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <cstdlib>
#include <sstream>
using namespace std;
int main(){
	int N;
	cin >> N;
	for(int i=0;i<N;i++){
		string key[]={".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
		string input;
		cin>>input;
		stringstream b(input);
		int num=0,count=0;
		while(1){
			char c;
			if(!(b>>c))break;
			int input=c-'0';
			if(input!=0){
				count++;
				num=input;
			}
			else {
				if(count!=0)
					cout<<key[num-1][(count-1)%key[num-1].size()];
				num=0;count=0;
			}
		}
		cout<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
string order;
vector<int> num;
vector<char> word;
int n;
char button[9][4] = {{'.',',','!','?'},{'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 main()
{
  int but = 0,push = 0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> order;
    for(int j=0;j<order.size();j++){
      num.push_back((int)(order[j]-'0'));
    }
    for(int j=0;j<num.size();j++){
      if(1<=num[j] && num[j]<=9 && but==0){
	but = num[j];
      }else if(1<=num[j] && num[j]<=9 && but!=0){
	push++; //cout << "pushed" << endl;
      }else if(num[j]==0 && but && but!=1 && but!=7 && but!=9){
	word.push_back(button[but-1][push%3]); //cout << button[but-1][push%3] << endl;
	push = 0;
	but = 0;
      }else if(num[j]==0 && but && (but==7 || but==9)){
	word.push_back(button[but-1][push%4]); //cout << button[but-1][push%4] << endl;
	push = 0;
	but = 0;
      }else if(num[j]==0 && but && but==1){
	word.push_back(button[but-1][push%4]); //cout << button[but-1][push%4] << endl;
	push = 0;
	but = 0;
      }else if(num[j]==0 && !but){
	continue;
      }
    }
    for(int k=0;k<word.size();k++){
      cout << word[k];
    }
    cout << endl;
    word.clear();
    num.clear();
  }
  
  return 0;
  
}