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 <stdio.h>
#include <stdlib.h>
#include <string.h>

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

int data_len[10] = {1,5,3,3,3,3,3,4,3,4};

char out[256][2048],answer[256][2048];

int main(void){
    int k,c;
    scanf("%d",&c);
    for(k=0;k<c;k++){
      int i,j=0,count=-1,length,num,flag=0;
      char input[2048],input_num[2];
      char now;
      scanf("%s",input);
      length = strlen(input);
      input_num[1]='\0';
      now = input[0];
      for(i=0;;i++){
        if(input[i]=='\0') break;
        if(now==input[i]) count++;
        else{
          input_num[0] = now;
          out[k][j] = data[atoi(input_num)][count%data_len[atoi(input_num)]];
          j++;
          count = -1;
          now = input[i];
          i--;
        }
      }
      j = 0;
      for(i=0;i<strlen(out[k]);i++){
        if(out[k][i]!='*'){
          answer[k][j] = out[k][i];
          j++;
      }
      }
    }
    for(k=0;k<c;k++){
        printf("%s\n",answer[k]);
    }
    return 0;
}

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

int main(){
  int n, l, c, s;
  string str, ans;
  map<int, string> m;
  m[1] = ".,!? ";
  m[2] = "abc";
  m[3] = "def";
  m[4] = "ghi";
  m[5] = "jkl";
  m[6] = "mno";
  m[7] = "pqrs";
  m[8] = "tuv";
  m[9] = "wxyz";
  cin >> n;
  for (int i = 0; i < n; ++i){
    cin >> str;
    c = 0;
    l = str.length();
    ans = "";
    s = 0;
    for (int j = 0; j < l; ++j){
      int S = str[j] - 48;
      if (s == S) c++;
      else  if (S == 0){
	c %= m[s].length();
	ans += m[s][c];
	c = -1;
	s = S;
      }else{
	s = S;
	c = 0;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

#define PI 4*atan(1)
#define INF 1e8

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

vector<string> button = {".,!?",
           "abc",
           "def",
           "ghi",
           "jkl",
           "mno",
           "pqrs",
           "tuv",
           "wxyz"};


int main(){
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    string s;
    cin >> s;
    int cnt = 0;
    for(int j = 0; j < s.size(); j++){
      if(s[j] == '0'){
        if(cnt != 0){
          int num = s[j-1] - '0';
          char c = button[num - 1][(cnt-1)%button[num-1].size()];
          cout << c;
          cnt = 0;
        }
      }else{
        cnt++;
      }
    }
    cout << endl;
  }
}

C++: #include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n;
    cin >> n;
    string a[10] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxvz"};
    while (n--){
        string s;
        cin >> s;
        int p = -1;
        REP(i,s.length()){
            int x = s[i] - '0';
            if (x == 0 && p >= 0){
                int y = s[i-1]-'0';
                cout << a[y][p % a[y].length()];
                p = -1;
            }
            if (x > 0) p++;
        }
        cout << endl;
    }

    return 0;
}

C++: #include <iostream>
#include <queue>
#include <string>
using namespace std;
int main(){
	string bottun[10] = { "0", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };
	queue<char> str;
	int n, i;
	cin >> n;
	while( n-- > 0 ){
		char s[1025];
		cin >> s;
		for( i = 0; s[i] != '\0'; i++ ){
			str.push(s[i]);
		}
		int t = 0, num = 0;
		while( !str.empty() ){
			if( str.front() == '0' && num != 0 ){
				cout << bottun[num][(t-1)%bottun[num].length()];
				t = -1;
			}
			num = (int)(str.front() - '0');
			str.pop();
			t++;
		}
		cout << endl;
	}
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>

using namespace std;

#define all(i) i.begin(), i.end()
#define rep(i,n) for(int i=0;i<n;i++)

int main()
{
	int num = 0; cin >> num;
	string dat[12] = { "", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };
	rep(i, num)
	{
		string str; cin >> str;
		vector<int> hit(10, 0);
		rep(j, (int)str.size())
		{
			hit[str[j] - '0'] += 1;
			if (j == 0 || str[j - 1] == '0') {}
			else if (str[j] == '0')
			{
				int tmp = str[j - 1] - '0', n = hit[tmp];
				while (1)
				{
					if (n <= (int)dat[tmp].size()) { break; }
					n -= (int)dat[tmp].size();
				}
				printf("%c", dat[tmp][n - 1]);
				rep(i, 10) { hit[i] = 0; }
			}
		}
		printf("\n");
	}
	return 0;
}

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

string s,ans;
int n,num,now;
int csize[10]={0,5,3,3,3,3,3,4,3,4};
char btn[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','-'}
};

int main(){
  int i,a,j;
  cin >> n;
  for(a=0;a<n;a++){
    ans="";
    cin >> s;
    for(i=0;i<s.size();i++){
      now = s[i]-'0';
      num=0;
      if(now==0)continue;
      while(s[++i]==now+'0')num++;
      ans+=btn[now][num%csize[now]];
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
using namespace std;
int main() {
	string a;
	string d[10] = { "",".,!? ","abc","def","ghi","jkl","mno",
		"pqrs","tuv","wxyz" };
	while (cin >> a) {
		string c = "";
		 for (int i = 0; i < a.length();) {
			while (a[i] == '0'&&i<a.length())i++;
			if (i == a.length()) break;
			int j = i;
			while (a[j] == a[i]&&i<a.length()) {
				i++;
			}
			int sum = i - j-1;
			sum %= d[(int)a[j] - '0'].length();
			if(i<a.length()&&a[i]=='0')c += d[(int)a[j] - '0'][sum];
		}
		 if (c != "") cout << c << endl;
	}
}