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<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef pair<ll,ll> pll;

#define reps(i,f,n) for(int i = int(f); i <= int(n); i++)
#define rep(i,n) reps(i,0,int(n)-1)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back

char str[12][5] ={"",".,!?","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
int mod[12] = {0,4,3,3,3,3,3,4,3,4};

int main(void){
  int n;
  cin >> n;
  rep(test,n){
    string s;
    cin >> s;
    int num = -1;
    int cnt = -1;
    rep(i,s.sz){
      if(s[i] == '0'){
        if(num != -1){
          printf("%c", str[num][cnt%mod[num]]);
          num = -1;
          cnt = -1;
        }
      }else{
        num = s[i] - '0';
        cnt++;
      }
    }
    puts("");
  }
  return 0;
}

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

using namespace std;

//10進数1桁の文字を整数型にする
int toInt(char c){
	return c - '0';
}

int main(){
	const char buttonTable[10][5]={{},//確定ボタン　0
							{'.', ',' ,'!', ' '},//1 (5)
							{'a','b','c'},//2 (3)
							{'d','e','f'},//3 (3)
							{'g','h','i'},//4 (3)
							{'j','k','l'},//5 (3)
							{'m','n','o'},//6 (3)
							{'p','q','r','s'},//7 (4)
							{'t','u','v'},//8 (3)
							{'w','x','y','z'}};//9(4)
	const int bsize[10] = {0,5,3,3,3,3,3,4,3,4};//ボタンの文字の種類
	
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		char command[1025];//char command[1025];
		cin >> command;
		int len = strlen(command);
		char result[76];//作ったメッセージ。サイズは[1,76) \0を忘れずに
		int idx = 0;//resultの入力場所
		int row=0;//ボタンを押した場所。表の行(row)
		int col=0;//同じボタンを押した回数。表の列(column)
		for(int j=0;j<len;j++){
			int button = toInt(command[j]);
			if(button == 0){
				if(row != 0){//文字を入力できる
					result[idx] = buttonTable[row][col];
					idx++;
					row = 0;
					col = 0;
				}
			}else if(button == row){
				col = (col+1)%bsize[button];
				
			}else{//文字を決定した次のコマンド
				row = button;
				//colの値は必ず0
			}
		}
		//result[idx] = '\0';
		//cout << idx << endl;
		//cout <<result << endl;
		for(int i=0;i<idx;i++){//文字列はidx文字ある
			cout << result[i];
		}
		cout << endl;
	}
	return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  char key[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;
  cin >> n;
  string s;
  for(int i=0;i<n;i++){
    string ans="";
    int a=0,b=0;
    cin >> s;
    for(int j=0;j<s.length();j++){
      if(s[j]=='0'){
        if(a){
          ans+=key[a-1][b];
          a=0;
          b=0;
        }
      }else{
        if(a){
          b++;
          if(a==1) b%=5;
          else if(a==7||a==9) b%=4;
          else b%=3;
        }else{
          a=s[j]-'0';
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef pair<ll,ll> pll;

#define reps(i,f,n) for(int i = int(f); i <= int(n); i++)
#define rep(i,n) reps(i,0,int(n)-1)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back

char str[12][6] ={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
int mod[12] = {0,5,3,3,3,3,3,4,3,4};

int main(void){
  int n;
  cin >> n;
  rep(test,n){
    string s;
    cin >> s;
    int num = -1;
    int cnt = -1;
    rep(i,s.sz){
      if(s[i] == '0'){
        if(num != -1){
          printf("%c", str[num][cnt%mod[num]]);
          num = -1;
          cnt = -1;
        }
      }else{
        num = s[i] - '0';
        cnt++;
      }
    }
    puts("");
  }
  return 0;
}

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

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

int main(){
    int n;
    
    cin >> n;
    while(n--){
        string str,tmp = "";
        cin >> str;

        int cnt = 0 ,t = 0;
        string s = "";
        for(int i = 0 ; i < str.size() ; i++){
            if(str[i]=='0'){
                if(!cnt) continue;
                tmp += key[t][cnt-1];
                t = cnt = 0;
            }
            else{
                t = str[i]-'0';
                if((cnt>2)&&(t==2||t==3||t==4||t==5||t==6||t==8)) cnt -= 3;
                else if((cnt>3)&&(t==7||t==9)) cnt -= 4;
                else if((cnt>4)&&t==1) cnt -= 5;
                cnt++;
            }
        }
        cout << tmp << endl;
    }
    
    return 0;
}

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

int main(){
	int n, len;
	cin >> n;
	for(int i = 0; i < n; ++i){
		string str;
		cin >> str;
		len = str.length();
		string ans;
		char ch = 0;
		for(int j = 0; j < len; ++j){
			if(str[j] == '0' && ch != 0){ 
				ans.push_back(ch);
				ch = 0;
			}else if(str[j] == '1'){
				if(ch == '.'){
					ch = ',';
				}else if(ch == ','){
					ch = '!';
				}else if(ch == '!'){
					ch = '?';
				}else if(ch == '?'){
					ch = ' '; 
				}else{
					ch = '.';
				}
			}else if(str[j] == '2'){
				if(ch == 'a'){
					ch = 'b';
				}else if(ch == 'b'){
					ch = 'c';
				}else{
					ch = 'a';
				}
			}else if(str[j] == '3'){
				if(ch == 'd'){
					ch = 'e';
				}else if(ch == 'e'){
					ch = 'f';
				}else{
					ch = 'd';
				}
				
			}else if(str[j] == '4'){
				if(ch == 'g'){
					ch = 'h';
				}else if(ch == 'h'){
					ch = 'i';
				}else{
					ch = 'g';
				}
			}else if(str[j] == '5'){
				if(ch == 'j'){
					ch = 'k';
				}else if(ch == 'k'){
					ch = 'l';
				}else{
					ch = 'j';
				}
			}else if(str[j] == '6'){
				if(ch == 'm'){
					ch = 'n';
				}else if(ch == 'n'){
					ch = 'o';
				}else{
					ch = 'm';
				}
				
			}else if(str[j] == '7'){
				if(ch == 'p'){
					ch = 'q';
				}else if(ch == 'q'){
					ch = 'r';
				}else if(ch == 'r'){
					ch = 's';
				}else{
					ch = 'p';
				}
			}else if(str[j] == '8'){
				if(ch == 't'){
					ch = 'u';
				}else if(ch == 'u'){
					ch = 'v';
				}else{
					ch = 't';
				}
			}else if(str[j] == '9'){
				if(ch == 'w'){
					ch = 'x';
				}else if(ch == 'x'){
					ch = 'y';
				}else if(ch == 'y'){
					ch = 'z';
				}else{
					ch = 'w';
				}
			}
		}
		cout << ans << endl;
	}
}

C++: 5
20
220
222220
44033055505550666011011111090666077705550301110
000555555550000330000444000080000200004440000