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<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int num; cin >> num;
    for(int n; n < num; n++){
        string number; cin >> number;
        REP(i, number.size()){
            char out;
            int kai = 0;
            if(number[i] == '1'){
                while(number[i] != '0'){
                    kai++;
                    if(kai == 6) kai = 1;
                    if(kai == 1) out = '.';
                    else if(kai == 2) out = ',';
                    else if(kai == 3) out = '!';
                    else if(kai == 4) out = '?';
                    else if(kai == 5) out = ' ';
                    i++;
                }
                cout << out;
            }
            if(number[i] == '2'){
                while(number[i] != '0'){
                    kai++;
                    if(kai == 4) kai = 1;
                    if(kai == 1) out = 'a';
                    else if(kai == 2) out = 'b';
                    else if(kai == 3) out = 'c';
                    i++;
                }
                cout << out;
            }
            if(number[i] == '3'){
                while(number[i] != '0'){
                    kai++;
                    if(kai == 4) kai = 1;
                    if(kai == 1) out = 'd';
                    else if(kai == 2) out = 'e';
                    else if(kai == 3) out = 'f';
                    i++;
                }
                cout << out;
            }
            if(number[i] == '4'){
                while(number[i] != '0'){
                    kai++;
                    if(kai == 4) kai = 1;
                    if(kai == 1) out = 'g';
                    else if(kai == 2) out = 'h';
                    else if(kai == 3) out = 'i';
                    i++;
                }
                cout << out;
            }
            if(number[i] == '5'){
                while(number[i] != '0'){
                    kai++;
                    if(kai == 4) kai = 1;
                    if(kai == 1) out = 'j';
                    else if(kai == 2) out = 'k';
                    else if(kai == 3) out = 'l';
                    i++;
                }
                cout << out;
            }
            if(number[i] == '6'){
                while(number[i] != '0'){
                    kai++;
                    if(kai == 4) kai = 1;
                    if(kai == 1) out = 'm';
                    else if(kai == 2) out = 'n';
                    else if(kai == 3) out = 'o';
                    i++;
                }
                cout << out;
            }
            if(number[i] == '7'){
                while(number[i] != '0'){
                    kai++;
                    if(kai == 5) kai = 1;
                    if(kai == 1) out = 'p';
                    else if(kai == 2) out = 'q';
                    else if(kai == 3) out = 'r';
                    else if(kai == 4) out = 's';
                    i++;
                }
                cout << out;
            }
            if(number[i] == '8'){
                while(number[i] != '0'){
                    kai++;
                    if(kai == 4) kai = 1;
                    if(kai == 1) out = 't';
                    else if(kai == 2) out = 'u';
                    else if(kai == 3) out = 'v';
                    i++;
                }
                cout << out;
            }
            if(number[i] == '9'){
                while(number[i] != '0'){
                    kai++;
                    if(kai == 5) kai = 1;
                    if(kai == 1) out = 'w';
                    else if(kai == 2) out = 'x';
                    else if(kai == 3) out = 'y';
                    else if(kai == 4) out = 'z';
                    i++;
                }
                cout << out;
            }
        }
        cout << endl;
    }
}

C++: #include<iostream>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)

string in;
int j = 0;
int index = -1;

string c_1 = ".,!? " ;
string c_2 = "abc";
string c_3 = "def";
string c_4 = "ghi";
string c_5 = "jkl";
string c_6 = "mno";
string c_7 = "pqrs";
string c_8 = "tuv";
string c_9 = "wxyz";

char func(string s)
{
	while (in[j] != '0')
	{
		index++;
		if (index >= s.size())index = 0;
		j++;
	}
	return s[index];
}

int main()
{
	int n;
	cin >> n;
	cin.ignore();
	REP(i, n)
	{
		in.clear();
		getline(cin, in);
		j = 0;
		while (in[j] != '\0')
		{
			index = -1;
			switch (in[j])
			{
			case '1':
				cout << func(c_1);
				break;
			case '2':
				cout << func(c_2);
				break;
			case '3':
				cout << func(c_3);
				break;
			case '4':
				cout << func(c_4);
				break;
			case '5':
				cout << func(c_5);
				break;
			case '6':
				cout << func(c_6);
				break;
			case '7':
				cout << func(c_7);
				break;
			case '8':
				cout << func(c_8);
				break;
			case '9':
				cout << func(c_9);
				break;
		    }
			j++;
		}
		cout << endl;
	}
	return 0;
}

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

int main(){
  int prev=10,n,c=0;
  string str;
  char s,buf='\0';
  char keymap[9][5]={ {'.',',','!','?',' '},
		      {'a','b','c','\0','\0'},
		      {'d','e','f','\0','\0'},
		      {'g','h','i','\0','\0'},
		      {'j','k','l','\0','\0'},
		      {'m','n','o','\0','\0'},
		      {'p','q','r','s','\0'},
		      {'t','u','v','\0','\0'},
		      {'w','x','y','z','\0'}};
  cin>>n;

  while(n--){
    cin>>str;
    for(int i=0;i<str.length();i++){
      s=str.at(i);
      if(c!=0&&s=='0')cout<<buf,c=0,buf=0;
      switch (s){
      case '1':
	buf=keymap[0][(c++)%5];
	break;
      case '2':
	buf=keymap[1][(c++)%3];
	break;
      case '3':
	buf=keymap[2][(c++)%3];
	break;
      case '4':
	buf=keymap[3][(c++)%3];
	break;
      case '5':
	buf=keymap[4][(c++)%3];
	break;
      case '6':
	buf=keymap[5][(c++)%3];
	break;
      case '7':
	buf=keymap[6][(c++)%4];
	break;
      case '8':
	buf=keymap[7][(c++)%3];
	break;
      case '9':
	buf=keymap[8][(c++)%4];
	break;
      }
    }
    buf=0;
    cout<<endl;
  }
}