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 <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <numeric>
#include <algorithm>
using namespace std;
int n;

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

C++: #include<bits/stdc++.h>

using namespace std;
using LL = long long;

int main(){
    int n;cin >> n;
    vector<vector<char>> bottoms = {{'.', ',', '!', '?', ' '},
                                    {'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'},
                                   };
    for(int i = 0;i < n;i++){
        string s;cin >> s;
        vector<int> indexes(9);
        string ans;
        for(char c : s){
            if(c == '0'){
                for(int a = 0;a < 9;a++){
                    if(indexes.at(a) != 0){
                        ans += bottoms.at(a).at((indexes.at(a)-1)%(bottoms.at(a).size()));
                        indexes = vector<int>(9,0);
                        break;
                    }
                }
                continue;

            }
            int w = c - '1';
            indexes.at(w)++;
        }
        cout<<ans<<endl;
    }
}

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

using namespace std;

int main(){
	char moji[10][6];
	strcpy(moji[1],".,!? ");
	strcpy(moji[2] ,"abc  ");
strcpy(moji[3], "def  ");
strcpy(moji[4],"ghi  ");
strcpy(moji[5],"jkl  ");
strcpy(moji[6],"mno  ");
strcpy(moji[7],"pqrs ");
strcpy(moji[8],"tuv  ");
strcpy(moji[9],"wxyz ");

	string str;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>str;
		int cnt=0;
		int num=0;
		for(int j=0;j<str.size();j++){
			if(str.at(j)=='0')continue;
			cnt=0;
			num=str.at(j)-'0';
			if(j==str.size()-2){
				cout<<moji[num][cnt];
				break;
			}

			while(str.at(j)==str.at(j+1)){
				cnt++;
				j++;
				if(j==str.size()-2){
					break;
				}
			}

			if(num==1){
				cnt%=5;
			}
			else if(num==7||num==9){
				cnt%=4;
			}
			else{
				cnt%=3;
			}

			cout<<moji[num][cnt];
		}
		cout<<endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
string s,data[9]={
    ".,!? ",
    "abc",
    "def",
    "ghi",
    "jkl",
    "mno",
    "pqrs",
    "tuv",
    "wxyz"
};
int n,i,p,t;
int main(){
	cin>>n;while(n--){
		cin>>s,t=1,p=s[0]-'0';
		for(i=1;i<s.length();i++){
			if(s[i]=='0'){
				if(p!=0)cout<<data[p-1][(t-1)%data[p-1].length()];
				i++,p=s[i]-'0',t=1;
			}else if(p==0)p=s[i]-'0';
			else t++;
		}
		cout<<endl;
	}
}