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

package main

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

// 標準入力を取得するScannerのインスタンスを作成
var scanner = bufio.NewScanner(os.Stdin)

// 標準入力で各行を読み込みstringとして返す
func readLine() string {
	if scanner.Scan() {
		return scanner.Text()
	}
	return ""
}

func main() {
	// 1: . , ! ? (スペース)
	// 2: a b c
	// 3: d e f
	// 4: g h i
	// 5: j k l
	// 6: m n o
	// 7: p q r s
	// 8: t u v
	// 9: w x y z
	// 0: 確定ボタン

	// 改行から空白区切りに変更
	scanner.Split(bufio.ScanWords)
	line, _ := strconv.Atoi(readLine()) // 5行標準入力が続く

	table := []string{
		"",      // 0 index調整ためダミーデータ
		".,!? ", // 1
		"abc",   // 2
		"def",   // 3
		"ghi",   // 4
		"jkl",   // 5
		"mno",   // 6
		"pqrs",  // 7
		"tuv",   // 8
		"wxyz"}  // 9

	// 5行分の標準入力を格納するsliceを作成する
	messages := make([]string, 0, line)

	// sliceに標準入力の内容を格納する
	for i := 0; i < line; i++ {
		messages = append(messages, readLine()) // messages=[20 220 222220 44033055505550666011011111090666077705550301110 000555555550000330000444000080000200004440000]
	}

	// 各行毎に解析する
	for _, message := range messages { // message=000555555550000330000444000080000200004440000
		// 0で分割する
		messageSlice := strings.Split(message, "0") // messageSlice=[   55555555    33    444    8    2    444    ]
		for _, word := range messageSlice {
			if word == "" {
				// NOP.
				// 0をセパレーターにしているので空文字がsliceに格納されてい箇所がある
				// 何もしない
			} else { // word=55555555
				// 一文字取り出しコード値をASCII文字に変換する
				ascii := string((word[0])) // word[0]=5

				// ASCII文字からintへ変換する(tableのindexになる)
				number, _ := strconv.Atoi(ascii)

				// 入力回数をカウントする
				count := len(word) // 5

				// 同じ数字を続けて入力すると変化する文字はループすることを考慮する
				for count > len(table[number]) { // 5 > 3
					count -= len(table[number]) // 2
				}

				// キー配列
				keys := table[number]                   //jkl
				fmt.Printf("%s", string(keys[count-1])) //k
			}
		}
		fmt.Println() // 改行
	}
}

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

int main(void){

    vector<vector<char> > number(10);
    number[1].push_back('.');
    number[1].push_back(',');
    number[1].push_back('!');
    number[1].push_back('?');
    number[1].push_back(' ');

    number[2].push_back('a');
    number[2].push_back('b');
    number[2].push_back('c');

    number[3].push_back('d');
    number[3].push_back('e');
    number[3].push_back('f');

    number[4].push_back('g');
    number[4].push_back('h');
    number[4].push_back('i');

    number[5].push_back('j');
    number[5].push_back('k');
    number[5].push_back('l');

    number[6].push_back('m');
    number[6].push_back('n');
    number[6].push_back('o');

    number[7].push_back('p');
    number[7].push_back('q');
    number[7].push_back('r');
    number[7].push_back('s');

    number[8].push_back('t');
    number[8].push_back('u');
    number[8].push_back('v');

    number[9].push_back('w');
    number[9].push_back('x');
    number[9].push_back('y');
    number[9].push_back('z');    

    int n; cin >> n;
    for(int i = 0; i < n; i++){
        string str; cin >> str;
        int j = 0;
        while(str[j] != '\0'){
            int counter = 0;
            if(str[j] == '0'){ 
                j++;
                continue;
            }
            while(str[j] != '0'){
                counter++;
                j++;
            }
            //cout << j - 1 << endl;
            //cout << str[j - 1] << endl;
            //int a = str[j - 1];
            //cout << counter << endl;
            //cout << a << endl;
            //cout << number[ a ].size() << endl;
            //cout << number[2].size() << endl;
            //cout << counter / number[j - 1].size() << endl;
            //cout << counter << " " << str[j - 1] << endl;
            cout << number[(int)str[j - 1] - '0'][(counter-1) % number[(int)str[j - 1] - '0'].size()];
            j++;
        }

        cout << endl;
    }

    return 0;
}

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

int main() {
    vector<vector<char>> v = { {'.', ',', '!', '?', ' '},
                               {'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 n;
    cin >> n;
    for(int i=0; i<n; ++i) {
        string str;
        cin >> str;
        int counter = -1;
        int id = -1;
        for(int j=0; j<str.size(); ++j) {
            char c = str[j];
            if(c == '0' && id != -1) {
                cout << v[id][counter];
                id = -1;
                counter = -1;
            } else if(c != '0') {
                id = static_cast<int>(c - '0' - 1);
                counter = (counter+1)%v[id].size();
            }
        }
        cout << endl;
    }
}

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

using namespace std;

int main(void){
	vector<vector<string>> moji{
		{}, 
		{".",",","!","?"," "},
		{"a","b","c"},
		{"d","e","f"},
		{"f","h","i"},
		{"j","k","l"},
		{"m","n","o"},
		{"p","q","r","s"},
		{"t","u","v"},
		{"w","x","y","z"}
	};

	int num;
	cin >> num;
	for(int i = 0; i < num; i++){
		int count = 0;
		string str;
		cin >> str;
		string one = "0";

		for(int j = 0; j < str.size(); j++){
			if(str[j] == '0'){
				if(one != "0"){
					count--;
					cout << moji[stoi(one)][count % moji[stoi(one)].size()];
				}
				one = str[j];
				count = 0;
			}else{
				one = str[j];
				count++;
			}
		}
		cout << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main() {
	int n; cin >> n;
	string s[10];
	s[0] = '0';
	s[1] = ".,!? ";
	s[2] = "abc";
	s[3] = "def";
	s[4] = "ghi";
	s[5] = "jkl";
	s[6] = "mno";
	s[7] = "pqrs";
	s[8] = "tuv";
	s[9] = "wxyz";
	for (int i = 0; i < n; i++) {


		string num;
		cin >> num;
		for (int j = 0; j < num.size(); j++) {
			if (j == 0) {
				if (num[j] == '0') {
					continue;
				}
			}

			else if (num[j - 1] == '0'&&num[j] == '0') {
				continue;
			}
			int t = 0;
			while (num[j + t] != '0')t++;
			switch (num[j]) {
			case '1':cout << s[1][(t - 1) % 5]; break;
			case '2':
			case '3':
			case '4':
			case '5':
			case '6':cout << s[num[j] - '0'][(t - 1) % 3]; break;
			case '7':cout << s[7][(t - 1) % 4]; break;
			case '8':cout << s[num[j] - '0'][(t - 1) % 3]; break;
			case '9':cout << s[9][(t - 1) % 4]; break;
			default:break;
			}
			j += t;
		}
		cout << endl;






	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <cstdlib>
#include <sstream>
using namespace std;
int main(){
	int N;
	cin >> N;
	for(int i=0;i<N;i++){
		string key[]={".,!?, ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
		string input;
		cin>>input;
		stringstream b(input);
		int num=0,count=0;
		while(1){
			char c;
			if(b>>c)break;
			int input=c-'0';
			if(input!=0){
				count++;
				num=input;
			}
			else {
				if(count!=0)
					count<<key[num-1][count%key[num-1].size()];
				num=0;count=0;
			}
		}
		cout<<endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
string c[11] = {"",
		".,!? ",
		"abc",
		"def",
		"ghi",
		"jkl",
		"mno",
		"pqrs",
		"tuv",
		"wxyz"};
int main(void){
  int n;
  cin >> n;
  string s;
  for(int i = 0; i < n; i++){
    string res;
    cin >> s;
    char a = '0';
    int b = 0;
    for(int j = 0; j < (int)s.size(); j++){
      if(s[j] == a){
	b++;
      }else{
	if(a-'0')
	  res += c[a-'0'][b%(int)c[a-'0'].size()];
	a = s[j];
	b = 0;
      }
    }
    cout << res << endl;
  }
}