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

int main() {
  vector<char> c[10];
  c[1].push_back('.');
  c[1].push_back(',');
  c[1].push_back('!');
  c[1].push_back('?');
  c[1].push_back(' ');
  c[2].push_back('a');
  c[2].push_back('b');
  c[2].push_back('c');
  c[3].push_back('d');
  c[3].push_back('e');
  c[3].push_back('f');
  c[4].push_back('g');
  c[4].push_back('h');
  c[4].push_back('i');
  c[5].push_back('j');
  c[5].push_back('k');
  c[5].push_back('l');
  c[6].push_back('m');
  c[6].push_back('n');
  c[6].push_back('o');
  c[7].push_back('p');
  c[7].push_back('q');
  c[7].push_back('r');
  c[7].push_back('s');
  c[8].push_back('t');
  c[8].push_back('u');
  c[8].push_back('v');
  c[9].push_back('w');
  c[9].push_back('x');
  c[9].push_back('y');
  c[9].push_back('z');

  int n;
  cin >> n;
  while(n--) {
    string s;
    cin >> s;
    string t="";
    int cnt=-1;
    for(int i=0; i<s.size(); i++) {
      if(s[i]!='0') {
	cnt++;
      } else {
	int x=(int)s[i-1]-48;
	if(cnt!=-1) t+=c[x][cnt%c[x].size()];
	cnt=-1;
      }
    }
    cout << t << endl;
  }
  return 0;
}

C++: #include <cstdio>
int main(){
  int N,p,g,a[9]={};
  int i,o;
  char v,prev;
  scanf("%d",&N);
  for(i=1;i<=N+1;i++){
    p=0;
    while(1){
      p++;
      scanf("%c",&v);
      if(v=='\n') break;
      if(v=='1') a[0]++;
      if(v=='2') a[1]++;
      if(v=='3') a[2]++;
      if(v=='4') a[3]++;
      if(v=='5') a[4]++;
      if(v=='6') a[5]++;
      if(v=='7') a[6]++;
      if(v=='8') a[7]++;
      if(v=='9') a[8]++;
      if(v=='0') {
	if(prev=='1') {
	  if(a[0]%5==4) printf("?");
	  if(a[0]%5==1) printf(".");
	  if(a[0]%5==2) printf(",");
	  if(a[0]%5==3) printf("!");
	  if(a[0]%5==0) printf(" ");
	}
	if(prev=='2'){
	  g=a[1]%3;
	  if(g==0) g=3;
	  printf("%c",96+g);
	}
	if(prev=='3'){
	  g=a[2]%3;
	  if(g==0) g=3;
	  printf("%c",99+g);
	}
	if(prev=='4'){
	  g=a[3]%3;
	  if(g==0) g=3;
	  printf("%c",102+g);
	}
	if(prev=='5'){
	  g=a[4]%3;
	  if(g==0) g=3;
	  printf("%c",105+g);
	}
	if(prev=='6'){
	  g=a[5]%3;
	  if(g==0) g=3;
	  printf("%c",108+g);
	}
	if(prev=='7'){
	  g=a[6]%4;
	  if(g==0) g=4;
	  printf("%c",112+g);
	}
	if(prev=='8'){
	  g=a[7]%3;
	  if(g==0) g=3;
	  printf("%c",115+g);
	}
	if(prev=='9'){
	  g=a[8]%4;
	  if(g==0) g=4;
	  printf("%c",118+g);
	}
	for(o=0;o<8;o++){
	  a[o]=0;
	}
      } 
      prev=v;
    }
    if(i>=2)   printf("\n");
  }
  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<iostream>
#include<vector>
#include<algorithm>
#include<string>

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

using namespace std;

int main(){
    string keitai[10] =
        {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
    string str;
    int n; cin >> n;
    REP(k,n){
        str.clear();
        cin >> str;
        int len = str.size();
        int cur=0, cnt=0;
        int tmp;
        REP(i,len){
            if(str[i]=='0'){ //00???????????¨???cnt=0
                if(cnt!=0){
                    if(cnt % keitai[cnt].size()==0){
                        tmp = keitai[cnt].size() - 1;
                    }else{
                        tmp = cnt % keitai[cnt].size() - 1;
                    }
                    cout << keitai[cur][tmp];
                }
                cur=0; cnt=0;
            }else{ //str[i]!='0'
                if(cur==0){//0??\?????\????????????
                    cur = str[i] - '0';
                    cnt++;
                }else{
                    cnt++;
                }
            }
        }
        cout << endl;
    }
    return 0;
}

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

int main(){
  int n;
  string bottan[]={
    "",
    ".,!? ", // 1
    "abc", // 2
    "def", // 3
    "ghi", // 4
    "jkl", // 5
    "mno", // 6
    "pqrs", // 7
    "tuv", // 8
    "wxyz", // 9
  };
  int cnt[] = {0,5,3,3,3,3,3,4,3,4};
  
  cin >> n;
  while(n--){
    string str; cin >> str;
    int len = str.size();
    int cnt1=0,cnt2=0;
    for(int i=0;i<len;i++){
      if(str[i] == '0'){
	if(cnt1 != 0){
	  if(cnt2%cnt[cnt1] == 0){
	    cout << bottan[cnt1][cnt[cnt1]-1];
	  }
	  else {
	    cout << bottan[cnt1][cnt2%cnt[cnt1]-1];
	  }
	}
	cnt1 = 0; cnt2 = 0;
      }
      else {
	if(cnt1 == 0){
	  cnt1 = str[i] - '0';
	  cnt2++;
	}
	else {
	  cnt2++;
	}
      }
    }
    cout << endl;
  }
}

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

int ch_num( char m ){
	if( m == '0' ) return 0 ;
	if( m == '1' ) return 1 ;
	if( m == '2' ) return 2 ;
	if( m == '3' ) return 3 ;
	if( m == '4' ) return 4 ;
	if( m == '5' ) return 5 ;
	if( m == '6' ) return 6 ;
	if( m == '7' ) return 7 ;
	if( m == '8' ) return 8 ;
	if( m == '9' ) return 9 ;
}

char word_map[9][6] = {
	{'.',',','!','?',' '} , // 5
	{'a','b','c','0','0'} ,
	{'d','e','f','0','0'} ,
	{'g','h','i','0','0'} ,
	{'j','k','l','0','0'} ,
	{'m','n','o','0','0'} ,
	{'p','q','r','s','0'} , // 4
	{'t','u','v','0','0'} ,
	{'w','x','y','z','0'} // 4
} ;

int main(){
	
	int n ;
	string s ;
	
	cin >> n ;
	for( int i=0 ; i<n ; i++ ){
		cin >> s ;
		for( int j=0 ; j<s.size() ; j++ ){
			int cnt = 0 , p = 3 , q = 1 ;
			char a = s[j] ;
			if( s[j] == '0' ) continue ;
			if( s[j] == '1' ) p = 5 ;
			if( s[j] == '6' || s[j] == '8' ) p = 4 ;
			for( int k=j+1 ; k<s.size() ; k++ ){
				if( s[k] == a ) cnt++ ;
				if( s[k] != a ) break ;
				q++ ;
			}
			j += q ;
			cout << word_map[ch_num(a)-1][cnt%p] ;
		}
		cout << endl ;
	}
	
return 0 ;
}