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>

char f(int on, int cnt){
	if(on==1){
		if(cnt==1)return '.';
		if(cnt==2)return ',';
		if(cnt==3)return '!';
		if(cnt==4)return '?';
		if(cnt==0)return ' ';
	}else if(on==2){
		if(cnt==1)return 'a';
		if(cnt==2)return 'b';
		if(cnt==0)return 'c';
	}else if(on==3){
		if(cnt==1)return 'd';
		if(cnt==2)return 'e';
		if(cnt==0)return 'f';
	}else if(on==4){
		if(cnt==1)return 'g';
		if(cnt==2)return 'h';
		if(cnt==0)return 'i';
	}else if(on==5){
		if(cnt==1)return 'j';
		if(cnt==2)return 'k';
		if(cnt==0)return 'l';
	}else if(on==6){
		if(cnt==1)return 'm';
		if(cnt==2)return 'n';
		if(cnt==0)return 'o';
	}else if(on==7){
		if(cnt==1)return 'p';
		if(cnt==2)return 'q';
		if(cnt==3)return 'r';
		if(cnt==0)return 's';
	}else if(on==8){
		if(cnt==1)return 't';
		if(cnt==2)return 'u';
		if(cnt==0)return 'v';
	}else if(on==9){
		if(cnt==1)return 'w';
		if(cnt==2)return 'x';
		if(cnt==3)return 'y';
		if(cnt==0)return 'z';
	}
}

int main(){
	int n;
	std::cin >> n;
	for(int i = 0; i < n; ++i){
		std::string s;
		std::cin>>s;
		int key[10];
		for(int i=0;i<10;++i)key[i]=0;
		int on=0;
		for(int i = 0; i < s.size();++i){
			if(s[i]!='0'){
				key[s[i]-'0']++;
				on=s[i]-'0';
				
			}else{
				if(on){
					int cnt=key[on];
					if(on==7 || on==9 && key[on]>=4)cnt%=4;
					else if(on==1 && key[on]>=5)cnt%=5;
					else if(on>=1 && on<=9 && on!=9 && on!=7 && on!=1 && key[on]>=3)cnt%=3;
					std::cout<<f(on,cnt);
					//std::cout<<key[on]<<std::endl;
					for(int i=0;i<10;++i)key[i]=0;
				}
				on=0;
			}//44033055505550666011011111090666077705550301110
		}
		std::cout<<std::endl;
	}
	return 0;
}

C++: #include <iostream>
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)

using namespace std;

int main()
{
  char keitai[10][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;
  cin.ignore();
  string s;
  int x , c;
  char p;
  REP(k, n){
    getline(cin, s);
    x = c = 0;
    p = '\0';
    REP(i, s.size()){
      int j;
      j = s[i] - '0';
      if(j){
        if(x == j){
          if(keitai[j][c + 1] == '*'){
            c = 0;
            p = keitai[j][c];
          }else{
            c++;
            p = keitai[j][c];
          }
        }else{
          c = 0;
          p = keitai[j][c];
        }
      }else{
        if(p != '\0')
          cout << p;
        p = '\0';
      }
      x = j;
    }
    cout << endl;
  }
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}


int main(){
	vector<string>keistr(10);
	keistr[1] = ".,!? ";
	keistr[2] = "abc";
	keistr[3] = "def";
	keistr[4] = "ghi";
	keistr[5] = "jkl";
	keistr[6] = "mno";
	keistr[7] = "pqrs";
	keistr[8] = "tuv";
	keistr[9] = "wxyz";
	int n;
	cin >> n;
	REP(i,n){
		string in_str;
		cin >> in_str;
		int cnt = -1;
		REP(j,in_str.size()){
			if(in_str[j]=='0'){
				if(cnt>=0){
					int pos = in_str[j-1] - '0';
					cout << keistr[pos][cnt%keistr[pos].size()];
					cnt = -1;
				}
			}else{
				cnt++;
			}
		}
		cout  << endl;
	}
}

C++: #include <iostream>
#include <string>
using std::cin;
using std::cout;
using std::endl;
using std::string;

int main(){
  string kigo = ".,!? ";
  string a = "abc";
  string d = "def";
  string g = "ghi";
  string j = "jkl";
  string m = "mno";
  string p = "pqrs";
  string t = "tuv";
  string w = "wxyz";
  string syu;
  int keta,n,count;
  int flag1 = 0;
  int flag2 = 0;
  cin >> n;
  string nn;
  for(int i = 0; i < n;i++){
    cin >> nn;
    syu = "";
    for(int i = 0; i < nn.length();i++){
      if(nn[i] == '1'){
        flag1 = 1;
        flag2 += 1;
      }else if(nn[i] == '2'){
        flag1 = 2;
        flag2 += 1;
      }else if(nn[i] == '3'){
        flag1 = 3;
        flag2 += 1;
      }else if(nn[i] == '4' ){
        flag1 = 4;
        flag2 += 1;
      }else if(nn[i] == '5'){
        flag1 = 5;
        flag2 += 1;
      }else if(nn[i]== '6'){
        flag1 = 6;
        flag2 += 1;
      }else if(nn[i] == '7'){
        flag1 = 7;
        flag2 += 1;
      }else if(nn[i] == '8'){
        flag1 = 8;
        flag2 += 1;
      }else if(nn[i] == '9'){
        flag1 = 9;
        flag2 += 1;
      }else if(nn[i] == '0'){
        if(flag1 == 0){
        }else{
          flag2 -= 1;
          if(flag1 == 1){
            syu += kigo[(flag2)%5];
            flag1 = 0;
          }else if(flag1 == 2){
            syu += a[flag2%3];
            flag1 = 0;
          }else if(flag1 == 3){
            syu += d[flag2%3];
            flag1 = 0;
          }else if(flag1 == 4){
            syu += g[flag2%3];
            flag1 = 0;
          }else if(flag1 == 5){
            syu += j[flag2%3];
            flag1 = 0;
          }else if(flag1 == 6){
            syu += m[flag2%3];
            flag1 = 0;
          }else if(flag1 == 7){
            syu += p[flag2%4];
            flag1 = 0;
          }else if(flag1 == 8){
            syu += t[flag2%3];
            flag1 = 0;
          }else if(flag1 == 9){
            syu += w[flag2%4];
            flag1 = 0;
          }
          flag2 = 0;
        }
      }
    }
      cout << syu << endl;
  }
}

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

using namespace std;

int main() {

    int n;
    string s;

    char ntoc[9][6] = {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};

    cin >> n;

    while(n-- && cin >> s) {

        int len = s.size();
        int p = -1;

        for(int i = 0; i < len; ++i) {
            if(p == -1) {
                if(s[i] != '0') {
                    p = (s[i] - '1') * 10;
                }
            } else {
                if(s[i] == '0') {
                    cout << ntoc[p / 10][p % 10];
                    p = -1;
                } else {
                    p = (p / 10 * 10) + (p % 10 + 1) % strlen(ntoc[p / 10]);
                }
            }
        }

        cout << endl;

    }

}