Go: // Keitai Message
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2006&lang=jp
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n := nextInt(sc)

	for i := 0; i < n; i++ {
		message := nextString(sc)
		currentButton, count := 0, 0
		for _, word := range message {
			// 確定の処理を書く
			if word == '0' {
				if currentButton == 0 {
					count = 0
					continue
				}
				mod := len(table[currentButton])
				tmp := table[currentButton][(count-1)%mod]
				currentButton, count = 0, 0
				fmt.Printf("%c", tmp)
			} else {
				count++
				currentButton = int(word) - 48 // '0'はASCIIで48
			}
		}
		fmt.Println()
	}
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (int)n;i++)
#define repb(i,n) for(int i = (int)n;i >= 0;i--)
#define reps(i,m,n) for(int i = (int)m;i < (int)n;i++)
#define repsb(i,m,n) for(int i = (int)m;i >= (int)n;i--)
#define SORT(v,n) sort(v,v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define INF 999999999999999999
#define ll long long int
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1;} return 0;}
using namespace std;
string s[] = {".,!? ", "abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    rep(i,n){
        string tmp,ans="";
        int cnt=0,al=0;
        cin >> tmp;
        rep(j,tmp.size()){
            if (j>0&&tmp[j]!='0'&&tmp[j] == tmp[j - 1])
            {
                cnt++;
                //cout << "cnt" << cnt << endl;
                if (tmp[j] == '1')
                {
                    cnt %= 5;
                }
                else if (( tmp[j] == '7' ||tmp[j] == '9') )
                {
                    cnt %= 4;
                }
                else{
                    cnt %= 3;
                }
            }
            if(j>0&&tmp[j-1]!='0'&&tmp[j]=='0'){
                //cout << j - 1 << endl;
                ans += s[tmp[j - 1] - '0' - 1][cnt];
                cnt = 0;
            }
            
        }
        cout << ans<<endl;

    }
    return 0;
}

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

int main(){
	int n;
	string m;
	string word[] = { ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> m;
		int btn = 0;
		int cnt = 0;
		for (int j = 0; j < m.length(); j++){
			if (m[j] != '0'){
				btn = (int)(m[j] - '0');
				cnt++;
				switch (btn){
					case 1:
						if (cnt > 5){
							cnt = 1;
						}
						break;
					case 7:
					case 9:
						if (cnt > 4){
							cnt = 1;
						}
						break;
					case 2:
					case 3:
					case 4:
					case 5:
					case 6:
					case 8:
						if (cnt > 3){
							cnt = 1;
						}
						break;
				}
			}
			else{
				if (cnt > 0){
					cout << word[btn - 1][cnt-1];
					cnt = 0;
				}
			}
		}
		cout << endl;
	}
}

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

int n;
string s;
string alpha[9] = {
	".,!? ",
	"abc",
	"def",
	"ghi",
	"jkl",
	"mno",
	"pqrs",
	"tuv",
	"wxyz",
};

int main(void){
	cin>>n;
	while(n--){
		char before = '0';
		int count = -1;
		cin>>s;
		for(int i=0;i<s.length();i++){
			if(s[i] == '0' && before != '0'){
				int idx = before - '1';
				cout<<alpha[idx][count%alpha[idx].length()];
				count = -1;
			}
			else if(s[i] != '0'){
				count++;
			}

			before = s[i];
		}
		cout<<endl;
	}
}

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

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

int main()
{
	int n, p = 0, cnt;
	string key[] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
	string str;
	
	cin >> n;
	while (cin >> str) {
		for (char& c : str) {
			n = c - '0';
			if (n) {
				cnt++;
			} else if (p == n) {
			}else {
				cout << key[p][(cnt-1) % key[p].size()];
				cnt = 0;
			}
			p = n;
		}
		cout << endl;
	}
	
	return 0;
}

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

using namespace std;

int main(){
	
	int n;
	cin >> n;
	
	string btn[] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
	
	for(int k=0; k<n; ++k){
		
		string str, res="";
		cin >> str;
		int curr = 0;
		int ptr = -1, tmp;
		
		for(int i=0; i<str.size(); ++i){
			
			tmp = (int)(str[i]-'0');
			
			if(tmp==0){
				if(curr !=0)
					res += btn[curr][ptr];
				
				curr=0;
				ptr=-1;
				continue;
			}
			
			curr = tmp;
			ptr = (ptr+1)%btn[curr].size();
		}
		
		cout << res << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <string.h>
using namespace std;
int main(){
  int n,i,j,len,count,which,flag;
  char in[1025];
  char data[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'}
  };
  cin >> n;
  for(i=0;i<n;i++){
    cin >> in;
    len=strlen(in);
    count=-1;
    which=0;
    for(j=0;j<len;j++){
      flag=0;
      if(in[j]=='1') which=1;
      else if(in[j]=='2') which=2;
      else if(in[j]=='3') which=3;
      else if(in[j]=='4') which=4;
      else if(in[j]=='5') which=5;
      else if(in[j]=='6') which=6;
      else if(in[j]=='7') which=7;
      else if(in[j]=='8') which=8;
      else if(in[j]=='9') which=9;
      else{
        if(which==0) continue;
	if(which==1) count%=5;
	else if(which==2||which==3||which==4||which==5||which==6||which==8) count%=3;
	else if(which==7||which==9) count%=4;
	cout << data[which][count];
	flag=1;
        count=-1;
        which=0;
      }
      if(flag==0) count++;
    }
    cout << endl;
  }
  return 0;
}