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>
using namespace std;
const char button[10][6] = {	{},
								{'.',',','!','?',' '},
								{'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',}};
const int num[10] = {0,5,3,3,3,3,3,4,3,4};
int main()
{
	int n;
	cin >> n;
	char line[1024];
	for (int i = 0; i < n; i++)
	{
		cin >> line;
		int len = strlen(line);
		int j = 0;
		while (j < len)
		{
			int next = j + 1;
			int count = 0;
			while(next < len  && line[next] == line[j])
			{
				next++;
				count++;
			}
			if ((line[j] - '0') != 0)
			{
				int number = line[j] - '0';
				int length = num[number];
				cout << button[number][count % length];
			}
			count = 0;
			j = next;
		}
		cout<<endl;

	}
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  for(int i=0;i<N;i++){
    string S;
    cin >> S;
    map<char,int> loop;
    map<char,map<int,char> > mp;
    mp['1'][0]='.';loop['1']=5;
    mp['1'][1]=',';
    mp['1'][2]='!';
    mp['1'][3]='?';
    mp['1'][4]=' ';
    mp['2'][0]='a';loop['2']=3;
    mp['2'][1]='b';
    mp['2'][2]='c';
    mp['3'][0]='d';loop['3']=3;
    mp['3'][1]='e';
    mp['3'][2]='f';
    mp['4'][0]='g';loop['4']=3;
    mp['4'][1]='h';
    mp['4'][2]='i';
    mp['5'][0]='j';loop['5']=3;
    mp['5'][1]='k';
    mp['5'][2]='l';
    mp['6'][0]='m';loop['6']=3;
    mp['6'][1]='n';
    mp['6'][2]='o';
    mp['7'][0]='p';loop['7']=4;
    mp['7'][1]='q';
    mp['7'][2]='r';
    mp['7'][3]='s';
    mp['8'][0]='t';loop['8']=3;
    mp['8'][1]='u';
    mp['8'][2]='v';
    mp['9'][0]='w';loop['9']=4;
    mp['9'][1]='x';
    mp['9'][2]='y';
    mp['9'][3]='z';
    char set='0';
    int count=0;
    for(int i=0;i<S.size();i++){
      if(S[i]=='0'){
        if(set!='0'){
          cout << mp[set][count%loop[set]];
          set='0';
        }
        count = 0;
      }else if(S[i]==set){
        count++;
      }else{
        set=S[i];
      }
    }
    cout << endl;
  }
}

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

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

using namespace std;

int main(){
    string keitai[10] =
        {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
    string str;
    int n; cin >> n;
    REP(k,n){
        cin >> str;
        int len = str.size();
        int cur=0, cnt=0;
        int tmp;
        REP(i,len){
            if(str[i]=='0'){ //00???????????¨???cnt=0
                if(cnt!=0){
                    if(cnt % keitai[cnt].size()==0){
                        tmp = keitai[cnt].size() - 1;
                    }else{
                        tmp = cnt % keitai[cnt].size() - 1;
                    }
                    cout << keitai[cur][tmp];
                }
                cur=0; cnt=0;
            }else{ //str[i]!='0'
                if(cur==0){//0??\?????\????????????
                    cur = str[i] - '0';
                    cnt++;
                }else{
                    cnt++;
                }
            }
        }
    }
    cout << endl;
    return 0;
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <fstream>
#include <stdio.h>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EPS 1e-8

char input[1025];
char g[]=".,!? abcdefghijklmnopqrstuvwxyz";
int h[]={5,3,3,3,3,3,4,3,4};
int k[10];

inline char gc(int b, int r){
	r=(r-1)%h[b];
	return g[k[b]+r];
}

int main(){
	int t;
	cin>>t;
	k[0] = 0;
	REP(i,9)k[i+1]=k[i]+h[i];
	REP(i,t){
		cin>>input;
		int n=strlen(input);
		int r=0;
		REP(j,n){
			if(input[j]!='0')r++;
			else{
				if(r!=0)
					cout << gc(input[j-1]-'0'-1, r);
					r=0;
			
			}
		}
		cout << endl;

	}
}

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

int main(){
    char moji[][6] = {
        {'.',',','!','?',' '},
        {'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 jo[9] = {5,3,3,3,3,3,4,3,4};

    int n; cin>>n;

    for(int i=0; i<n; i++){
        string s; cin>>s;
        int count =-1;
        int v;

        for(int j=0; j<s.size(); j++){ 
            if(s[j] != '0'){
                v = s[j] - '0';
                v--;
                count++;
            }

            else{
                if(count == -1) continue;
                cout<<moji[v][count % jo[v]];
                count = -1;
            }
        }

        cout<<endl;
    }

    return 0;
}