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;
		now = "(";
		for ( int j = 0; j < str.size(); j++ ) {	
			if ( str[ j ] == '0' ) {
				if ( now[ 0 ] != '(' ) {
					cout << now;
					now[ 0 ] = '(';
					many_push = PII( 10, 10 );
				}
				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<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
  int n;
  cin>>n;
  for(int i=0; i<n; i++){
    string s;
    cin>>s;
    string c="";
    int cnt=0;
    char t[5];
    for(int i=0; i<s.size(); i++){
      cnt=0;
      if(s[i]=='1'){
        t[0]='.',t[1]=',',t[2]='!',t[3]='?',t[4]=' ';
        while(1){
          if(s[i]==s[i+1]){i++,cnt++;}
          else{break;}
        }
        if(s[i+1]=='0'){c+=t[cnt%5];}
      }
      else if(s[i]=='2'){
        t[0]='a',t[1]='b',t[2]='c';
        while(1){
          if(s[i]==s[i+1]){i++,cnt++;}
          else{break;}
        }
        if(s[i+1]=='0'){c+=t[cnt%3];}
      }
      else if(s[i]=='3'){
        t[0]='d',t[1]='e',t[2]='f';
        while(1){
          if(s[i]==s[i+1]){i++,cnt++;}
          else{break;}
        }
        if(s[i+1]=='0'){c+=t[cnt%3];}
      }
      else if(s[i]=='4'){
        t[0]='g',t[1]='h',t[2]='i';
        while(1){
          if(s[i]==s[i+1]){i++,cnt++;}
          else{break;}
        }
        if(s[i+1]=='0'){c+=t[cnt%3];}
      }
      else if(s[i]=='5'){
        t[0]='j',t[1]='k',t[2]='l';
        while(1){
          if(s[i]==s[i+1]){i++,cnt++;}
          else{break;}
        }
        if(s[i+1]=='0'){c+=t[cnt%3];}
      }
      else if(s[i]=='6'){
        t[0]='m',t[1]='n',t[2]='o';
        while(1){
          if(s[i]==s[i+1]){i++,cnt++;}
          else{break;}
        }
        if(s[i+1]=='0'){c+=t[cnt%3];}
      }
      else if(s[i]=='7'){
        t[0]='p',t[1]='q',t[2]='r',t[3]='s';
        while(1){
          if(s[i]==s[i+1]){i++,cnt++;}
          else{break;}
        }
        if(s[i+1]=='0'){c+=t[cnt%4];}
      }
      else if(s[i]=='8'){
        t[0]='t',t[1]='u',t[2]='v';
        while(1){
          if(s[i]==s[i+1]){i++,cnt++;}
          else{break;}
        }
        if(s[i+1]=='0'){c+=t[cnt%3];}
      }
      else if(s[i]=='9'){
        t[0]='w',t[1]='x',t[2]='y',t[3]='z';
        while(1){
          if(s[i]==s[i+1]){i++,cnt++;}
          else{break;}
        }
        if(s[i+1]=='0'){c+=t[cnt%4];}
      }
    }
    cout<<c<<endl;
  }
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i] >> y[i];
typedef long long int ll;
using namespace std;

string t[10]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
string s;
int main(){
	int a; cin >>a;
	for(int i=0;i<a;i++){
		cin >>s;
		int line=0;
		char now='0';
		for(int i=0;i<s.size();i++){
			if(now!=s[i]){
				if(now!='0'){
					cout << t[now-'0'][(line-1)%t[now-'0'].size()];
				}
				line=1;
				now=s[i];
			}
			else{
				line++;
			}
		}
		cout << endl;
	}
}