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>
using namespace std;

int main()
{
	int N;
	string str,res;
	cin >> N;
	for (int i = 0; i < N; i++) {
		res = "";
		cin >> str;
		char ch = 0;
		int inc = 0;
		for (int j = 0; j < str.length();j++) {
			switch (str[j]) {
			case '0':
				if (ch) {
					if (ch == '.') {
						if (inc % 5 == 0) {
							res += '.';
						}else if (inc % 5 == 1) {
							res += ',';
						}
						else if (inc % 5 == 2) {
							res += '!';
						}
						else if (inc % 5 == 3) {
							res += '?';
						}
						else if (inc % 5 == 4) {
							res += ' ';
						}
					} else if(ch == 'p' || ch == 'w')
						res += (char)(ch + (inc % 4));
					else
						res += (char)(ch + (inc % 3));
				}
				ch = 0;
				inc = 0;
				break;
			case '1':
				if (ch == '.')
					inc++;
				else
					ch = '.';
				break;
			case '2':
				if (ch == 'a')
					inc++;
				else
					ch = 'a';
				break;
			case '3':
				if (ch == 'd')
					inc++;
				else
					ch = 'd';
				break;
			case '4':
				if (ch == 'g')
					inc++;
				else
					ch = 'g';
				break;
			case '5':
				if (ch == 'j')
					inc++;
				else
					ch = 'j';
				break;
			case '6':
				if (ch == 'm')
					inc++;
				else
					ch = 'm';
				break;
			case '7':
				if (ch == 'p')
					inc++;
				else
					ch = 'p';
				break;
			case '8':
				if (ch == 't')
					inc++;
				else
					ch = 't';
				break;
			case '9':
				if (ch == 'w')
					inc++;
				else
					ch = 'w';
				break;
			}
		}
		if(ch) {
			if (ch == '.') {
				if (inc % 5 == 0) {
					res += '.';
				}
				else if (inc % 5 == 1) {
					res += ',';
				}
				else if (inc % 5 == 2) {
					res += '!';
				}
				else if (inc % 5 == 3) {
					res += '?';
				}
				else if (inc % 5 == 4) {
					res += ' ';
				}
			}
			else if (ch == 'p' || ch == 'w')
				res += (char)(ch + (inc % 4));
			else
				res += (char)(ch + (inc % 3));
		}
		cout << res << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
string kei[] = {".,!? ","abc","def","ghi",
		"jkl","mno","pqrs","tuv","wxyz",};

int main(){
  string str;
  int n;
  cin >> n;
  while(n--){
    cin >> str;
    int cnt = 0;
    for(int i = 0 ; i < str.size()-1 ; i++ ){
      if(str[i] == str[i+1] && str[i] != '0')cnt++;
      if(str[i] == '0' && str[i+1] == '0')continue;
      if(str[i]!='0' && str[i+1] == '0'){
	cout << kei[(str[i]-'0')-1][cnt%(kei[(str[i]-'0')-1].size())];  
	cnt = 0;
      }
    }
    cout << endl;
  }
}

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;
      }
      if(flag==0) count++;
    }
    cout << endl;
  }
  return 0;
}

C++: #include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
vector <char> v;
vector<string>ansl;
string s;
string ans;
int main(){
  int N;
  char mozi[][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'}};

  cin >>N;

  for(int i=0;i<N;i++){
    string ans;
    int ind = 0;
    cin >>s;
    for(ind = 0;ind<(int)s.size();ind++){
      int num = 0;

      while(s[ind] != '0'){
        num++;
        ind++;
      }
      int indx = stoi(&(s[ind-1]))-1;

      if(s[ind-1] == '1'){
        ans = ans + mozi[0][num%5];
      }else if((s[ind-1] == '4')||(s[ind] == '9')){
        ans = ans + mozi[indx][num%4];
      }else{
        ans = ans + mozi[indx][num%3];
      }
    }
    ansl.push_back(ans);
  }
  for (int i = 0;i<N;i++){
    cout <<ansl[i]<<endl;
  }

  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	char a[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 n,c=0,d=0;
	string s;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;d=c=0;
			for(int j=0;j<s.size();j++){
				if(s[j]=='0'&&c>0){
					if(s[j-1]=='1')d=(c-1)%5;
					else if(s[j-1]=='7'||s[j-1]=='9')d=(c-1)%4;
					else d=(c-1)%3;
					cout<<a[(int)(s[j-1]-'0')-1][d];
				c=0;
				}
				else if(s[j]=='0'&&s[j-1]=='0')c=0;
				else c++;
				}
				cout<<'\n';
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
char in[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 in1[9]={5,3,3,3,3,3,4,3,4};
int main(){
  int n;
  cin>>n;
  rep(j,n){
    string s;
    cin>>s;
    int i=0;
    while(i!=s.size()){
      int co=0;
      while(s[i]!='0'){
	co++;
	i++;
      }
      //cout<<co<<endl;
      if(co)cout<<in[s[i-1]-'0'-1][(co-1)%in1[s[i-1]-'0'-1]];
      i++;
    }
    cout<<endl;
  }
}