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>

using namespace std;

int main(){
    string str;

    while(cin >> str){
        int times = 0;
        char kind = 0;
        string ret = "";
        str += '0';
        for(int i=0;i<str.size();i++){
            if(str[i] == '0'){
                if(times != 0){
                    times--;
                    if(kind == '1'){
                        times %= 5;
                        if(times == 0){
                            ret += '.';
                        }else if(times == 1){
                            ret += ',';
                        }else if(times == 2){
                            ret += '!';
                        }else if(times == 3){
                            ret += '?';
                        }else{
                            ret += ' ';
                        }
                    }else if(kind == '2'){
                        ret += 'a' + (times%3);
                    }else if(kind == '3'){
                        ret += 'd' + (times%3);
                    }else if(kind == '4'){
                        ret += 'g' + (times%3);
                    }else if(kind == '5'){
                        ret += 'j' + (times%3);
                    }else if(kind == '6'){
                        ret += 'm' + (times%3);
                    }else if(kind == '7'){
                        ret += 'p' + (times%4);
                    }else if(kind == '8'){
                        ret += 't' + (times%3);
                    }else if(kind == '9'){
                        ret += 'w' + (times%4);
                    }
                }
                times = 0;
            }else{
                times++;
                kind = str[i];
            }
        }
        cout << ret << endl;
    }
}

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

int main(){
  string s;
  int N;
  char bot[10][20]={"0",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"}; 

  int count=0,flag=0;
  while(cin>>N){
    for(int i=0;i<N;i++){
      count=0;
      s.clear();
      cin>>s;
      for(int j=0;j<(int)s.size();j++){
	if(s[j]!='0'&&flag==0){
	  flag=s[j]-'0';
	}else if(flag!=0&&s[j]!='0'){
	  count++;
	}else if(s[j]=='0'&&flag!=0){
	  if(count<0&&count<=strlen(bot[flag]))cout<<bot[flag][count];
	  else{
	    while(count>strlen(bot[flag])-1){
	      count=count-strlen(bot[flag]);
	    }

	    cout<<bot[flag][count];
	  }
	  count=0;
	  flag=0;
	}
      }
      cout<<endl;
    }
  }
  return 0;
}

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

#define rep(i,n) for(unsigned int i=0; i<n; i++)

void solve(void){

	int m;					//文字列の行数
	std::string sl;		//文字列格納用ストリング型変数

	char c[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'},
	};

	std::cin >> m;
	while(m--){

		int t = 0;

		std::cin >> sl;

		rep(i,sl.size()-1){
			if(sl[i] == sl[i+1]){
				t++;
			}else{
				if(sl[i]=='7' || sl[i]=='8'){
					t %= 4;
				}
				else if(sl[i]=='1'){
					t %= 5;
				}else{
					t %= 3;
				}
				if(sl[i] != '0'){
					std::cout << c[sl[i]-'0'][t];
				}
				t = 0;
			}
		}
		std::cout << std::endl;
	}
}

int main(void){

	solve();

	return 0;
}

C++: #include<iostream>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<climits>
#include<ctime>
#include<cstring>
#define REP(i,p,n) for(int i=p;i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep_split(tok,a_str,re) for(char *tok = strtok((char *)a_str.c_str(),re); tok != NULL; tok = strtok(NULL,re))
#define all(c) (c).begin(), (c).end()

using namespace std;
template<class T> inline void chmax(T& a, T b) { if(b > a) a = b; }
template<class T> inline void chmin(T& a, T b) { if(b < a) a = b; }


int main() {
	int T;
	int num=0,back_number;
	int index_tok=-1;
	int len_tokens[10] = {0,5,3,3,3,3,3,4,3,4};
	int tokens[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','#'}
	};

	cin >> T;
	string a_str;
	rep(t,T) {
		cin >> a_str;
		back_number = 0;
		rep(i,a_str.size()) 
		{
			num = a_str[i] - '0';
			if (num == 0) {
				if (back_number != 0) {
					char a_char = tokens[back_number][index_tok];
					cout << a_char;
					index_tok = -1; //Enterしたら、一番先頭へ
				}
			}
			else {
				index_tok = (index_tok+1) % len_tokens[num];
			}
			back_number=num;
		}
		cout << endl;
	}

	return 0;
}

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

int table_r[10]={0,5,3,3,3,3,3,4,3,4};
char t[10][5] = {{0,0,0,0,0},{'.', ',', '!', '?', ' '},};

int main(){
    char abc='a';
    for(int i=2; i<=9; i++){
        for(int j=0; j<table_r[i]; j++){
            t[i][j]=abc++;
        }
    }

    int n;
    cin >> n;
    char buf[1025];
    for(int i=0; i<n; i++){
        cin >> buf;
        for(int j=0; buf[j]!=0; j++){
            char tmp = buf[j];
            if(tmp=='0') continue;
            int ct;
            for(ct=0; buf[j+ct]!=0; ct++){
                if(buf[j+ct]=='0'){
                    int k = tmp-'0';
                    cout << t[k][(ct-1)%table_r[k]];
                    j+=ct;
                    break;
                }
            }
        }
        cout << endl;
    }
            
    return 0;
}