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 <iostream>
#include <string>

using namespace std;

int main()
{
    string messages[9]= {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        string msg;
        int count = 0;
        char prev = '0';

        cin >> msg;

        for (int j = 0; j < msg.size(); j++) {
            char c = msg[j];

            if (c == '0') {
                if (prev == '1') {
                    cout << messages[0][(count-1) % 5];
                } else if (prev == '2') {
                    cout << messages[1][(count-1) % 3];
                } else if (prev == '3') {
                    cout << messages[2][(count-1) % 3];
                } else if (prev == '4') {
                    cout << messages[3][(count-1) % 3];
                } else if (prev == '5') {
                    cout << messages[4][(count-1) % 3];
                } else if (prev == '6') {
                    cout << messages[5][(count-1) % 3];
                } else if (prev == '7') {
                    cout << messages[6][(count-1) % 4];
                } else if (prev == '8') {
                    cout << messages[7][(count-1) % 3];
                } else if (prev == '9') {
                    cout << messages[8][(count-1) % 4];
                }
                count = 0;
            } else {
                count++;
            }
            prev = msg[j];
        }
        cout << endl;
    }

    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;
int main(){
  char m[9][5]={{'.',',','!','?',' '},
		{'a','b','c','1','1'},
		{'d','e','f','1','1'},
		{'g','h','i','1','1'},
		{'j','k','l','1','1'},
		{'m','n','o','1','1'},
		{'p','q','r','s','1'},
		{'t','u','v','1','1'},
		{'w','x','y','z','1'}};

  int a,count=0,c[100],d;
  char b[100][1025];
  cin>>a;
  for(int i=0;i<a;i++){
    scanf("%s",b[i]);
    c[i]=strlen(b[i]);
    for(int j=0;j<c[i];j++){
      if(b[i][j]!='0')count++;
      else
	if(b[i][j-1]!=0){
	  d=(int)(b[i][j-1])-48;

	  if(d==1)
	    if(count%5!=0)
	      cout<<m[d-1][count%5-1];
	    else cout<<m[d-1][4];

	  else if(d==7 || d==9)
	    if(count%4!=0)
	      cout<<m[d-1][count%4-1];
	    else cout<<m[d-1][3];

	  else
	    if(count%3!=0)
	      cout<<m[d-1][count%3-1];
	    else cout<<m[d-1][2]; 
	  count=0;
	}
    }
    cout<<endl;
  }
  return 0;
}
#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;
int main(){
  char m[9][5]={{'.',',','!','?',' '},
		{'a','b','c','1','1'},
		{'d','e','f','1','1'},
		{'g','h','i','1','1'},
		{'j','k','l','1','1'},
		{'m','n','o','1','1'},
		{'p','q','r','s','1'},
		{'t','u','v','1','1'},
		{'w','x','y','z','1'}};

  int a,count=0,c[100],d;
  char b[100][1025];
  cin>>a;
  for(int i=0;i<a;i++){
    scanf("%s",b[i]);
    c[i]=strlen(b[i]);
    for(int j=0;j<c[i];j++){
      if(b[i][j]!='0')count++;
      else
	if(b[i][j-1]!=0){
	  d=(int)(b[i][j-1])-48;

	  if(d==1)
	    if(count%5!=0)
	      cout<<m[d-1][count%5-1];
	    else cout<<m[d-1][4];

	  else if(d==7 || d==9)
	    if(count%4!=0)
	      cout<<m[d-1][count%4-1];
	    else cout<<m[d-1][3];

	  else
	    if(count%3!=0)
	      cout<<m[d-1][count%3-1];
	    else cout<<m[d-1][2]; 
	  count=0;
	}
    }
    cout<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cstring>
#include <cstdlib>
using namespace std;
int main()
{
	int n, i, j, k, c, d, x;
	char s[1025], t[10][6] = {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> s;
		for (j = x = 0, d = 0; j < strlen(s); j++)
		{
			c = s[j] - '0';
			if (c == 0 && d != 0)
			{
				cout << t[d-1][x%strlen(t[d-1])];
			}
			else if (d == c)
			{
				x++;
			}
			else
			{
				x = 0;
			}
			d = c;
		}
		cout << endl;
	}
}

C++: #include <bits/stdc++.h>
#include <tuple>
#include <iterator>
using namespace std;
using ll = long long;

char t[][5] = {
    {},
    {'.', ',', '!', '?', ' '},
    {'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()
{
  int n;
  cin >> n;
  vector<string> ans;
  for (int i = 0; i < n; ++i)
  {
    string s;
    cin >> s;
    string sum = "";
    int cnt = 0;
    char c = '0';
    for (int j = 0; j < s.size(); ++j)
    {
      if (s[j] == '0')
      {
        if (c == '0')
          continue;
        if ((c - '0') == 1)
          sum += t[c - '0'][(cnt - 1) % 5];
        else if ((c - '0') == 7 || (c - '0') == 9)
          sum += t[c - '0'][(cnt - 1) % 4];
        else
          sum += t[c - '0'][(cnt - 1) % 3];
        cnt = 0;
        c = '0';
      }
      else
      {
        c = s[j];
        cnt++;
      }
    }
    ans.push_back(sum);
  }
  for (auto &e : ans)
    cout << e << endl;

  return 0;
}

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

using namespace std;

struct wait{
	char num;
	int count;
};

void out(int, int);

int main(){
	int n;
	string input;
	struct wait now;
	int i, j;
	
	cin >> n;
	for(i = 0; i < n; i++){
		now.count = 0;
		cin >> input;
		
		for(j = 0;j < input.size(); j++){
			if(input[j] == '0'){
				out(now.num - '0', now.count);
				now.count = 0;
			}
				
			else{
				now.num = input[j];
				now.count++;
			}
		}
		cout << endl;
	}
	
	return 0;
}

void out(int num, int count){
	char output[9][5] = {{'.', ',', '!', '?', ' '}, {'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 size[] = {5, 3, 3, 3, 3, 3, 4, 3, 4};
	int which;
	
	if(count == 0)
		return;
	
	if(count % size[num - 1] == 0)
		which = size[num - 1] - 1;
	else
		which = count % size[num - 1] - 1;
	cout << output[num - 1][which];
}