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 <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class T>
inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T>
inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    rep(i,N){
        string S; cin >> S;
        string A;
        int pos=0;
        while(SZ(S)>pos){
            int cnt=0;
            while(S[pos]!='0'){
                cnt++;
                pos++;
            }
            if(S[pos-1]=='1'){
                if(cnt%5==1) A+='.';
                else if(cnt%5==2) A+=',';
                else if(cnt%5==3) A+='!';
                else if(cnt%5==4) A+='?';
                else A+=' ';
            } else if(S[pos-1]=='2'){
                if(cnt%3==1) A+='a';
                else if(cnt%3==2) A+='b';
                else A+='c';
            } else if(S[pos-1]=='3'){
                if(cnt%3==1) A+='d';
                else if(cnt%3==2) A+='e';
                else A+='f';
            } else if(S[pos-1]=='4'){
                if(cnt%3==1) A+='g';
                else if(cnt%3==2) A+='h';
                else A+='i';
            } else if(S[pos-1]=='5'){
                if(cnt%3==1) A+='j';
                else if(cnt%3==2) A+='k';
                else A+='l';
            } else if(S[pos-1]=='6'){
                if(cnt%3==1) A+='m';
                else if(cnt%3==2) A+='n';
                else A+='o';
            } else if(S[pos-1]=='7'){
                if(cnt%4==1) A+='p';
                else if(cnt%4==2) A+='q';
                else if(cnt%4==3) A+='r';
                else A+='s';
            } else if(S[pos-1]=='8'){
                if(cnt%3==1) A+='t';
                else if(cnt%3==2) A+='u';
                else A+='v';
            } else if(S[pos-1]=='9'){
                if(cnt%4==1) A+='w';
                else if(cnt%4==2) A+='x';
                else if(cnt%4==3) A+='y';
                else A+='z';
            }
            pos++;
        }
        cout << A << endl;
    }
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin >> n;
  for(int w=0;w<n;w++){
  string s;
  cin >> s;
  char flag;
  char c,ans;
  int p =0;
  for(int i=0;i<s.size();i++){
    c = s[i]-'0';
    if(c==0&&flag!=0){
       p = 0;
       cout << ans;
     }
    if(c==1){
      if(p%5==0) ans = '.';
      if(p%5==1) ans = ',';
      if(p%5==2) ans = '!';
      if(p%5==3) ans = '?';
      if(p%5==4) ans = ' ';
      p++;
    }
    if(c==2){
      if(p%3==0) ans = 'a';
      if(p%3==1) ans = 'b';
      if(p%3==2) ans = 'c';
      p++;
    }
    if(c==3){
      if(p%3==0) ans = 'd';
      if(p%3==1) ans = 'e';
      if(p%3==2) ans = 'f';
      p++;
    }
    if(c==4){
      if(p%3==0) ans = 'g';
      if(p%3==1) ans = 'h';
      if(p%3==2) ans = 'i';
      p++;
    }
    if(c==5){
      if(p%3==0) ans = 'j';
      if(p%3==1) ans = 'k';
      if(p%3==2) ans = 'l';
      p++;
    }
    if(c==6){
      if(p%3==0) ans = 'm';
      if(p%3==1) ans = 'n';
      if(p%3==2) ans = 'o';
      p++;
    }
    if(c==7){
      if(p%4==0) ans = 'p';
      if(p%4==1) ans = 'q';
      if(p%4==2) ans = 'r';
      if(p%4==3) ans = 's';
      p++;
    }
    if(c==8){
      if(p%3==0) ans = 't';
      if(p%3==1) ans = 'u';
      if(p%3==2) ans = 'v';
      p++;
    }
    if(c==9){
      if(p%4==0) ans = 'w';
      if(p%4==1) ans = 'x';
      if(p%4==2) ans = 'y';
      if(p%4==3) ans = 'z';
      p++;
    }
    flag = c;
  }
  cout << endl;
}
}

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

int main(){

  string s[]={""," .,!?", "cab", "fde", "igh", "ljk", "omn", "spqr", "vtu", "zwxy"};
  int m[]={0, 5, 3, 3, 3, 3, 3, 4, 3, 4};
  string b;
  int n, cnt;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>b;
    cnt=0;
    for(int j=0;j<b.size();j++){
      if(b[j]=='0'){
	if(cnt){
	  cout<<s[b[j-1]-'0'][cnt%m[b[j-1]-'0']];
	  cnt=0;
	}
      }else cnt++;
    }
    cout<<endl;
  }
  
  return 0;
}

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

#define rep(i,n) for(unsigned int i=0; i<n; i++)

void solve(void){

	int m;					//文字列の行数
	std::string sl;		//文字列格納用ストリング型変数

	char c[10][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'},
	};

	std::cin >> m;
	while(m--){

		int t = 0;

		std::cin >> sl;

		rep(i,sl.size()-1){
			if(sl[i] == sl[i+1]){
				t++;
			}else{
				if(sl[i]=='7' || sl[i]=='8'){
					t %= 4;
				}
				else if(sl[i]=='1'){
					t %= 5;
				}else{
					t %= 3;
				}
				if(sl[i] != '0'){
					std::cout << c[sl[i]-'0'][t];
				}
				t = 0;
			}
		}
		std::cout << std::endl;
	}
}

int main(void){

	solve();

	return 0;
}

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

using namespace std;

string hyo[]={".,!? ",
	      "abc",
	      "def",
	      "ghi",
	      "jkl",
	      "mno",
	      "pqrs",
	      "tuv",
	      "wxyz",};

main(){
  string in;
  int n;
  cin>>n;
  while(n--){
    cin>>in;
    string out;
    int zen='0';
    int c=0;
    for(int i=0;i<in.size();i++){
      if(in[i]=='0' && zen!='0'){
	zen-='1';
	int s=hyo[zen].size();
	--c;
	c%=s;
	out+=hyo[zen][c];
	c=0;
	zen=in[i];
      }else if(in[i]=='0' && zen=='0'){
	continue;
      }else if(zen=='0' && in[i]!=0){
	c=1;
	zen=in[i];
      }else if(in[i]==zen){
	++c;
      }
    }
    cout<<out<<endl;
  }
}