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<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <functional>

using namespace std;

int INF = 10000000;

int n;

char table[10][7] = 
{
	{'\\'},
	{'.',',','!','?',' ','-'},
	{'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()
{
	cin >> n;

	for(int i = 0;i < n;i++)
	{
		char str[80];
		int cmax = 0;

		string input;

		cin >> input;

		int a,b = -1,c = 0;

		for(int j = 0;j < input.length();j++)
		{
			a = input[j] - '0';
			

			if(a == 0)
			{
				if(b != -1 && b != 0){str[cmax++] = table[b][c];str[cmax] = '\0';}
				b = -1;c = 0;
			}

			if(b == a)
			{
				c++;
				if(table[b][c] == '-')c = 0;
			}

			b = a;

		}

		cout << str << endl;

	}

  return 0;
}

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

int main() {
    int T; cin >> T;
    vector<string> tbl = {
        "ッターン！",
        ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"
    };
    while (T--) {
        string s; cin >> s;
        int key = 0, idx = -1;
        for (int i = 0; i < s.length(); i++) {
            if (s[i] == '0') {
                if (key) cout << tbl[key][idx];
                key = 0;
                idx = -1;
            } else {
                key = s[i] - '0';
                (idx += 1) %= tbl[key].size();
            }
        }
        cout << endl;
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
    char code[][5] = {
        {0,0,0,0,0},
        {'.',',','!','?',' '},
        {97,98,99,0,0},
        {100,101,102,0,0},
        {103,104,105,0,0},
        {106,107,108,0,0},
        {109,110,111,0,0},
        {112,113,114,115,0},
        {116,117,118,0,0},
        {119,120,121,122,0}
    };
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string input;
        cin >> input;
        int num = 0;
        int index = 0;
        for (int j = 0; j < input.length(); ++j) {
            if (str[j] == '0') {
                cout << code[num][index];
                num = 0;
                index = 0;
            } else if (!index && !num) {
                num = input[j] - '0';
            } else {
                ++index;
                while(num && !code[num][index]) {
                    if (++index == 5) index = 0;
                }
            }
        }
        cout << endl;
    }
}

C++: #include <stdio.h>
char RB[46]=".,!? abc  def  ghi  jkl  mno  pqrs tuv  wxyz ";char fuego(int here, int len) {int mod;if (here==1) mod=5; else if (here==9 || here==7) mod=4; else mod=3;return RB[(here-1)*5+len%mod];}
int main() {int len=0,val=0,N;char T;scanf("%d%*c",&N);while (N) {T=getchar();if (T>='0' && T<='9') {if (val!=T-48) {if (val) printf("%c",fuego(val,len));val=T-48,len=0;} else len++;} else {val=0,len=0,N--;puts("");}} return 0;}

C++: //Name: Keitai Message
//Level: 1
//Category: シミュレーション,やるだけ
//Note: 

/**
 * やるだけ。
 */
#include <iostream>
#include <string>

using namespace std;

const string tbl[10] = {
    "",
    ".,!? ",
    "abc",
    "def",
    "ghi",
    "jkl",
    "mno",
    "pqrs",
    "tuv",
    "wxyz"
};
bool solve(bool first) {
    string cmd;
    string ans;
    cin >> cmd;
    int row = 0, col = -1;
    for(char c : cmd) {
        if(c == '0') {
            if(col >= 0) ans += tbl[row][col % tbl[row].size()];
            col = -1;
        } else {
            row = c - '0';
            ++col;
        }
    }
    cout << ans << endl;
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);

    int N;
    cin >> N;
    bool first = true;
    while(N--) {
        solve(first);
        first = false;
    }
    return 0;
}

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

using namespace std;
 
string key[] = {"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
 
int main(){
    int n;
     
    cin >> n;
    while(n--){
        string str,tmp = "";
        cin >> str;
 
        int cnt = 0 ,t = 0;
        string s = "";
        for(int i = 0 ; i < str.size() ; i++){
            if(str[i]=='0'){
                if(!cnt) continue;
                tmp += key[t][cnt-1];
                t = cnt = 0;
            }
            else{
                t = str[i]-'0';
                if((cnt>2)&&(t==2||t==3||t==4||t==5||t==6||t==8)) cnt -= 3;
                else if((cnt>3)&&(t==7||t==9)) cnt -= 4;
                else if((cnt>4)&&t==1) cnt -= 5;
                cnt++;
            }
        }
        cout << tmp << endl;
    }
     
    return 0;
}

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

char const mozi1[]={'.',',','!','?',' '},mozi2[]={'a','b','c'},mozi3[]={'d','e','f'},mozi4[]={'g','h','i'},mozi5[]={'j','k','l'},mozi6[]={'m','n','o'},mozi7[]={'p','q','r','s'},mozi8[]={'t','u','v'},mozi9[]={'w','x','y','z'};
void henkan(char *);
char mozi(int,char);
int main(){
	int n;
	cin>>n;

	for(int i=0;i<n;i++){
		char * keitai=new char[1024];
		scanf("%s",keitai);
		henkan(keitai);
		delete[]keitai;
	}
	return 0;
}

void henkan(char * keitai){
	char *hyouzi=new char[72];
	fill(hyouzi,hyouzi+72,0);
	int length=strlen(keitai);
	int cnt=0;
	
	for(int i=0;i<length;i++){
		if(keitai[i]=='0')	continue;
		else{
			int kazu=1;
			while(keitai[i+1]!='0'){
				kazu++;
				i++;
			}
			hyouzi[cnt]=mozi(kazu,keitai[i]);
			i++;
			cnt++;
		}
	}
	
	cout<<hyouzi<<endl;
	delete[] hyouzi;
}
char mozi(int kazu,char keitai){
	switch (keitai)
	{
	case '1':
		kazu=kazu%5-1;
		if(kazu==-1)	return mozi1[4];
		return mozi1[kazu];
		
	case '2':
		kazu=kazu%3-1;
		if(kazu==-1)	return mozi2[2];
		return mozi2[kazu];
		
	case '3':
		kazu=kazu%3-1;
		if(kazu==-1)	return mozi3[2];
		return mozi3[kazu];
		
	case '4':
		kazu=kazu%3-1;
		if(kazu==-1)	return mozi4[2];
		return mozi4[kazu];
		
	case '5':
		kazu=kazu%3-1;
		if(kazu==-1)	return mozi5[2];
		return mozi5[kazu];
		
	case '6':
		kazu=kazu%3-1;
		if(kazu==-1)	return mozi6[2];
		return mozi6[kazu];
		
	case '7':
		kazu=kazu%4-1;
		if(kazu==-1)	return mozi7[3];
		return mozi7[kazu];
		
	case '8':
		kazu=kazu%3-1;
		if(kazu==-1)	return mozi8[2];
		return mozi8[kazu];
		
	case '9':
		kazu=kazu%4-1;
		if(kazu==-1)	return mozi9[3];
		return mozi9[kazu];
	default:
		return NULL;
	}
}