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;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 10007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { 1, -1, 0, 0,  1, -1,  1, -1 };
static const int dy[] = { 0, 0, 1, -1 , 1,  1, -1, -1 };

int n;
string str;
VS input(9);

string now = "(";
PII many_push;

int gcd( int m, int n ) {
	if ( n == 0 ) return m;
	return gcd( n, m % n );
}

int main() {
	input[ 0 ] = ".,!? ";
	input[ 1 ] = "abc";
	input[ 2 ] = "def";
	input[ 3 ] = "ghi";
	input[ 4 ] = "jkl";
	input[ 5 ] = "mno";
	input[ 6 ] = "pqrs";
	input[ 7 ] = "tuv";
	input[ 8 ] = "wxyz";
	scanf( "%d", &n );
	for ( int i = 0; i < n; i++ ) {
		cin >> str;
		many_push = PII( 10, 10 );
		for ( int j = 0; j < str.size(); j++ ) {	
			if ( str[ j ] == '0' ) {
				if ( now[ 0 ] != '(' ) {
					cout << now;
					now[ 0 ] = '(';
				}
				continue;
			}
			if ( many_push.first != str[ j ] - '1' ) {
				many_push = PII( str[ j ] - '1', 0 );
				now[ 0 ] = input[ many_push.first ][ many_push.second ];
				continue;
			}
			many_push.second++;
			many_push.second %= input[ many_push.first ].size();
			now[ 0 ] = input[ many_push.first ][ many_push.second ];
		}
		printf( "\n" );
	}
	return 0;
}

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

int main(){
	string key[10];
	key[0]="";
	key[1]=".,!? ";
	key[2]="abc";
	key[3]="def";
	key[4]="ghi";
	key[5]="jkl";
	key[6]="mno";
	key[7]="pqrs";
	key[8]="tuv";
	key[9]="wxyz";

	int m;
	cin >> m;
	for(int i=0;i<m;i++){
		string str;
		cin >> str;
		vector<char> res;
		int b=-1,n=-1;
		for(int i=0,a;i<str.length();i++,n++,b=a){
			a=(char)str[i]-'0';
			if(b!=-1&&b!=a){
				if(b!=0)
					res.push_back(key[b][n%key[b].length()]);
				n=-1;
			}
		}
		if(b!=0)
			res.push_back(key[b][n%key[b].length()]);


		string s(res.begin(),res.end());
		cout << s << endl;
	}

	return 0;
}

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

using namespace std;

string replaceAll(string &replacedStr, string from, string to){
    unsigned int pos = replacedStr.find(from);
    int toLen = to.length();

    if(from.empty()){
        return replacedStr;
    }

    while((replacedStr.find(from,pos)) != string::npos){
        pos = replacedStr.find(from,pos);
        replacedStr.replace(pos,from.length(),to);
        pos += toLen;
    }
    return replacedStr;
}

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        string a;
        cin >> a;
        for(int k=0;k<10;k++){
            replaceAll(a,"111111","1");
            replaceAll(a,"2222","2");
            replaceAll(a,"3333","3");
            replaceAll(a,"4444","4");
            replaceAll(a,"5555","5");
            replaceAll(a,"6666","6");
            replaceAll(a,"77777","7");
            replaceAll(a,"8888","8");
            replaceAll(a,"99999","9");
        }
        replaceAll(a,"111110"," ");
        replaceAll(a,"11110","?");
        replaceAll(a,"1110","!");
        replaceAll(a,"110",",");
        replaceAll(a,"10",".");
        replaceAll(a,"2220","c");
        replaceAll(a,"220","b");
        replaceAll(a,"20","a");
        replaceAll(a,"3330","f");
        replaceAll(a,"330","e");
        replaceAll(a,"30","d");
        replaceAll(a,"4440","i");
        replaceAll(a,"440","h");
        replaceAll(a,"40","g");
        replaceAll(a,"5550","l");
        replaceAll(a,"550","k");
        replaceAll(a,"50","j");
        replaceAll(a,"6660","o");
        replaceAll(a,"660","n");
        replaceAll(a,"60","m");
        replaceAll(a,"77770","s");
        replaceAll(a,"7770","r");
        replaceAll(a,"770","q");
        replaceAll(a,"70","p");
        replaceAll(a,"8880","v");
        replaceAll(a,"880","u");
        replaceAll(a,"80","t");
        replaceAll(a,"99990","z");
        replaceAll(a,"9990","y");
        replaceAll(a,"990","x");
        replaceAll(a,"90","w");
        replaceAll(a,"0","");
        cout << a << endl;
    }
}

C++: #include <iostream>
#include <cstdio>
#include <string>
#include <stack>
#include <queue>

using namespace std;

#define MAX 2048
string button[10] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};

int main(void) {
	int n, num = 0, count = 0;
	char nums[MAX];
	scanf("%d", &n);
	while(n--) {
		scanf("%s", nums);
		for(int i = 0; nums[i] != '\0'; i++) {
			if(nums[i] == '0') {
				if(num >= 1 && num <= 9) {
					printf("%c", button[num][(count + button[num].size() - 1) % button[num].size()]);
				}
				num = 0;
				count = 0;
			}
			else if(nums[i] == num + '0') {
				count++;
			} else {
				num = nums[i] - '0';
				count = 1;
			}
		}
		printf("\n");
	}
	return 0;
}