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;
vector<pair<int,int> > vpii(80);
string num;
void print(int s,int m,int f){
  switch(f-48){
  case 1:switch(s){
    case 1:cout<<'.';break; case 2:cout<<',';break; case 3:cout<<'!';break;case 4:cout<<'?';break; case 5:cout<<" ";break;}break;
  case 2:switch(s){
    case 1:cout<<'a';break; case 2:cout<<'b';break; case 3:cout<<'c';break;}break;
  case 3:switch(s){
    case 1:cout<<'d';break;case 2:cout<<'e';break;case 3:cout<<'f';break;}break;
  case 4:switch(s){
    case 1:cout<<'g';break;case 2:cout<<'h';break;case 3:cout<<'i';break;} break;
  case 5:switch(s){
    case 1:cout<<'j';break;case 2:cout<<'k';break;case 3:cout<<'l';break;} break;
  case 6:switch(s){
    case 1:cout<<'m';break;case 2:cout<<'n';break;case 3:cout<<'o';break;} break;
  case 7:switch(s){
    case 1:cout<<'p';break;case 2:cout<<'q';break;case 3:cout<<'r';break;case 4:cout<<'s';break;} break;
  case 8:switch(s){
    case 1:cout<<'t';break;case 2:cout<<'u';break;case 3:cout<<'v';break;}break; 
  case 9:switch(s){
    case 1:cout<<'w';break;case 2:cout<<'x';break;case 3:cout<<'y';break;case 4:cout<<'z';break;}break;
  default :break; 
  }
}
void dfs(int m,int d,int w,char f){
  if(w==d){
    print(d,m,f);
    return;
  }
  dfs(m,d,w+1,f);
  return;
}
int main(){
  int k=0,l=0,n;
  cin >> n;
  for(int q=0;q<n;q++){
    l=0;
    cin >> num;
    int a;
    for(int i=0;i<num.size();i++){
      if(i==0)
	a=num[0];
      k++;
      if(i!=0&&num[i]=='0' &&num[i-1]=='0'){
	k=0;
	continue;
      }
      if(num[i]!='0')
	a=num[i];
      if(num[i]=='0'){
	vpii[l]=make_pair(a,k-1);
	l++;
	k=0;
      }
    }
    for(int j=0;j<l;j++){
      int w=0;
      dfs(j,vpii[j].second,w,vpii[j].first);
    }
    cout<<endl;
  }
  return 0;
}

C++: #include<cstdio>
#include<cstring>
using namespace std;
int main(void)
{
	char mo[10][6]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
	char buf[1025];
	int le[10]={0,5,3,3,3,3,3,4,3,4};
	int i,j,wk,x,px,py,n,len;
	scanf("%d",&n);
	for(i=0;i<n;i++)	{
		scanf("%s",buf);
		len=strlen(buf);
		py=0;	px=-1;
		for(j=0;j<len;j++)	{
			x=buf[j]-'0';
			if(x==0)	{
				if(py!=0)	{
					printf("%c",mo[py][px]);
					py=0;	px=-1;
				}
			}
			else {
				py=x;
				px++;
				px=px%le[py];
			}
//			printf("py=%d px=%d\n",py,px);
		}
		printf("\n");
	}
		
	return 0;
}

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

int main(){

  string s1 = ".,!? ";
  string s2 = "abc";
  string s3 = "def";
  string s4 = "ghi";
  string s5 = "jkl";
  string s6 = "mno";
  string s7 = "pqrs";
  string s8 = "tuv";
  string s9 = "wxyz";
  string num;
  int n;
  cin >> n;
  while(n--){
    cin >> num;
    string ans = "";
    int len = num.size();
    int t1, t2, t3, t4, t5, t6 ,t7, t8, t9;
    t1 = t2 = t3 = t4 = t5 = t6 = t7 = t8 = t9 = 0;
    for(int i = 0; i < len; i++){
      if(num[i] == '0'){
        if(t1 > 0) ans += s1[(t1-1)%5];
        if(t2 > 0) ans += s2[(t2-1)%3];
        if(t3 > 0) ans += s3[(t3-1)%3];
        if(t4 > 0) ans += s4[(t4-1)%3];
        if(t5 > 0) ans += s5[(t5-1)%3];
        if(t6 > 0) ans += s6[(t6-1)%3];
        if(t7 > 0) ans += s7[(t7-1)%4];
        if(t8 > 0) ans += s8[(t8-1)%3];
        if(t9 > 0) ans += s9[(t9-1)%4];
        t1 = t2 = t3 = t4 = t5 = t6 = t7 = t8 = t9 = 0;
      }else{
        if(num[i] == '1') t1++;
        if(num[i] == '2') t2++;
        if(num[i] == '3') t3++;
        if(num[i] == '4') t4++;
        if(num[i] == '5') t5++;
        if(num[i] == '6') t6++;
        if(num[i] == '7') t7++;
        if(num[i] == '8') t8++;
        if(num[i] == '9') t9++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

typedef pair<char, int> P;
vector<P> v;

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

int main(){
	int n;
	cin >> n;
for(int i=0; i<n; i++){	
	
	string s;
	cin >> s;
	int len = s.size();
	
	int head = 0;
	for(int i=0; i < len; i++){
		if(s[i] == '0') head++;
		else break;
	}
	
	
	int body = -1;
	for(int i=head; i<len; i++){
		body++;
		if(s[i] == '0'){
			if(s[i-1] != '0'){
				v.push_back(P(s[i-1], body));
			}
			body = -1;
		}
	}
	
	for(int i=0; i<(int)v.size(); i++){
		cout << N2C(v[i].first, v[i].second);
	}
	cout << endl;
	
	v.clear();
	//debug
	/*
	for(int i=0; i<(int)v.size(); i++){
		cout << v[i].first << " " << v[i].second << endl;
	}
	*/
	
}//end	
	
	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
	int N;
	cin >> N;
	for(int i=0;i<N;i++){
		
		string key[]={".,!?, ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
	}
	return 0;
}