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>

using namespace std;

int main() {

    int n;
    string s;

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

    cin >> n;

    while(n-- && cin >> s) {

        int len = s.size();
        int p = -1;

        for(int i = 0; i < len; ++i) {
            if(p == -1) {
                if(s[i] != '0') {
                    p = (s[i] - '1') * 10;
                }
            } else {
                if(s[i] == '0') {
                    cout << ntoc[p / 10][p % 10];
                    p = -1;
                } else {
                    p = (p / 10 * 10) + (p % 10 + 1) % strlen(ntoc[p / 10]);
                }
            }
        }

        cout << endl;

    }

}

C++: #include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

// 文字列 split / デリミタに含まれるいずれかの文字で分割
vector<string> split( const string &str, const string &delim = " " )
{
	int start = 0, pos;
	vector<string> result;

	while ( ( pos = str.find_first_of( delim, start ) ) != string::npos )
	{
		result.push_back( str.substr( start, pos - start ) );
		start = pos + 1;
	}

	return result;
}

const VS BUTTONS = {
	"",
	".,!? ",
	"abc",
	"def",
	"ghi",
	"jkl",
	"mno",
	"pqrs",
	"tuv",
	"wxyz"
};

string solve( string line )
{
	VS chars( split( line, "0" ) );
	string res;

	REP( i, 0, chars.size() )
	{
		if ( !chars[i].size() )
		{
			continue;
		}

		const int pushed_button = chars[i][0] - '0';
		const int pushed_number = chars[i].size() - 1;
		res += BUTTONS[ pushed_button ][ pushed_number % BUTTONS[ pushed_button ].size() ];
	}

	return res;
}

int main()
{
	cin.tie( 0 );
	ios::sync_with_stdio( false );

	int n;
	cin >> n;
	REP( i, 0, n )
	{
		string line;
		cin >> line;
		cout << solve( line ) << endl;
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
    char table[9][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 youso[10] = {0,5,3,3,3,3,3,4,3,4},n;
    cin >> n;
    while(n--){
        int count=0,num,space,s;
        string str;
        cin >> str;
        for(int i=0;i<str.size();i++){
            num = int(str[i]-'0');
            if(num==0){
                if(count>0){
                     s = count%youso[space];
                     if(s==0)   s = youso[space];
                     cout << table[space-1][s-1];
                     count = 0;
                }
            }
            else{
                space=num;
                count++;
            }
        }
        cout << endl;
    }
}

C++: #include<bits/stdc++.h>
char change1[5]={' ','.',',','!','?'};
char change2[3]={'c','a','b'};
char change3[3]={'f','d','e'};
char change4[3]={'i','g','h'};
char change5[3]={'l','j','k'};
char change6[3]={'o','m','n'};
char change7[4]={'s','p','q','r'};
char change8[3]={'v','t','u'};
char change9[4]={'z','w','x','y'};
int cnt;
char change(char c){
    if(c=='1'){
        return change1[cnt%5];
    }
    else if(c=='2'){
        return change2[cnt%3];
    }
    else if(c=='3'){
        return change3[cnt%3];
    }
    else if(c=='4'){
        return change4[cnt%3];
    }
    else if(c=='5'){
        return change5[cnt%3];
    }
    else if(c=='6'){
        return change6[cnt%3];
    }
    else if(c=='7'){
        return change7[cnt%4];
    }
    else if(c=='8'){
        return change8[cnt%3];
    }
    else if(c=='9'){
        return change9[cnt%4];
    }
}
using namespace std;
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        vector<char> ans;
        cnt=0;
        char tmp;
        string s;
        cin>>s;
        for(int j=0;j<s.size();j++){
            if(s[j]=='0'){
                if(cnt!=0){
                    ans.push_back(change(tmp));
                    cnt=0;
                }
                else {continue;}
            }
            else{
                tmp=s[j];
                cnt++;
            }
        }
        for(int j=0;j<ans.size();j++){
            cout<<ans.at(j);
        }
        cout<<endl;
        
    }
    return 0;
}

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

int n;
string s;
vector< vector<char> > moji(10, vector<char>(0));

string solve() {
    string ans = "";
    char c;
    int count = 0;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == '0') {
            if (count==0) continue;
            int num = c - '0';
            // cout << moji[num].size() << endl;
            ans += moji[num][(count-1) % moji[num].size()];
            count = 0;
        }
        else {
            c = s[i];
            count++;
        }
        
    }
    return ans;
}

int main() {
    cin >> n;
    moji[1] = {'.', ',', '!', '?', ' '};
    moji[2] = {'a', 'b', 'c'};
    moji[3] = {'d', 'e', 'f'};
    moji[4] = {'g', 'h', 'i'};
    moji[5] = {'j', 'k', 'l'};
    moji[6] = {'m', 'n', 'o'};
    moji[7] = {'p', 'q', 'r', 's'};
    moji[8] = {'t', 'u', 'v'};
    moji[9] = {'w', 'x', 'y', 'z'};

    // moji.push_back({'.', ',', '!', '?', ' '});
    // moji.push_back({'a', 'b', 'c'});
    // moji.push_back({'d', 'e', 'f'});
    // moji.push_back({'g', 'h', 'i'});
    // moji.push_back({'j', 'k', 'l'});
    // moji.push_back({'m', 'n', 'o'});
    // moji.push_back({'p', 'q', 'r', 's'});
    // moji.push_back({'t', 'u', 'v'});
    // moji.push_back({'w', 'x', 'y', 'z'});


    for(int i = 0; i < n; i++) {
        cin >> s;
        cout << solve() << endl;
    }
}