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%5){
    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%3){
    case 1:cout<<'a';break; case 2:cout<<'b';break; case 3:cout<<'c';break;}break;
  case 3:switch(s%3){
    case 1:cout<<'d';break;case 2:cout<<'e';break;case 3:cout<<'f';break;}break;
  case 4:switch(s%3){
    case 1:cout<<'g';break;case 2:cout<<'h';break;case 3:cout<<'i';break;} break;
  case 5:switch(s%3){
    case 1:cout<<'j';break;case 2:cout<<'k';break;case 3:cout<<'l';break;} break;
  case 6:switch(s%3){
    case 1:cout<<'m';break;case 2:cout<<'n';break;case 3:cout<<'o';break;} break;
  case 7:switch(s%4){
    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%3){
    case 1:cout<<'t';break;case 2:cout<<'u';break;case 3:cout<<'v';break;}break; 
  case 9:switch(s%4){
    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 "bits/stdc++.h"
using namespace std;

int main() {
	int T;
	string S;
	vector<char> C[10];
	C[1] = { '.', ',', '!', '?', ' ' };
	for (int i = 2; i <= 7; i++) {
		for (int j = 0; j < 3; j++) C[i].push_back((char)('a' + (i - 2) * 3 + j));
	}
	C[7].push_back('s');
	C[8] = { 't', 'u', 'v' }, C[9] = { 'w', 'x', 'y', 'z' };
	cin >> T;
	for (int t = 0; t < T; t++) {
		cin >> S;
		int X = -1, Y = -1;
		for (int i = 0; i < S.size(); i++) {
			if (S[i] == '0') {
				if (X != -1) {
					cout << C[X][Y % C[X].size()];
				}
				X = -1, Y = -1;
			}
			else {
				if (S[i] - '0' == X) Y++;
				else X = S[i] - '0', Y = 0;
			}
		}
		cout << endl;
	}
}

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

int main() {

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


  int n;
  cin >> n;
  string str;
  for(int j=0;j<n;j++){
    cin >> str;
    int cnt = -1;
    int ima;
    for(int i=0;i<str.size();i++){
      if(cnt == -1 && str[i] == '0') continue;
      if(str[i] == '0'){
	cout <<key[ima][cnt%key[ima].size()];
	cnt = -1;
      }
      else{
	ima = str[i]-'0';
	cnt++;
      }   
    }
    cout << endl;
    
  }

    return 0;
}

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

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

int main(){
  cin >> N;
  
  for(int i=0; i<N; ++i){
    char input[1025];
    cin >> input;
    char old = '0';
    int count = 0;
    for(int j=0; input[j] != '\0'; ++j){
      if(input[j] == '0'){
        if(old != '0'){
          if('2' <= old && old <= '6' || old == '8'){
            putchar(phone[old-'1'][(count-1)%3]);
          }
          else if(old == '1'){
            putchar(phone[old-'1'][(count-1)%5]);
          }
          else{
            putchar(phone[old-'1'][(count-1)%4]);
          }
        }
        old = input[j];
        count = 0;
      }else{
        old = input[j];
        count++;
      }
    }
    cout << endl;
  }
  return 0;
}

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

using namespace std;

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

void solve(void) {
  string s;
  cin >> s;

  string ans = "";
  int l = 0;
  while (l < s.size()) {
    while (l < s.size() && s[l] == '0') l++;
    if (l == s.size()) break;

    int cnt = 0, p = s[l] - '0';
    while (l < s.size() && s[l] != '0') l++, cnt++;
    if (l == s.size()) break;    
    
    ans += b[p][(cnt - 1) % b[p].size()];
  }

  cout << ans << endl;
}

int main(void) {
  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    solve();
  }

  return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<cstring>
#include<utility>
#include<set>
#include<stack>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX  999999
int main(){
    char ans[][10] = {
        {},
        {'.',',','!','?',' '},
        {'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'}
    };
    ll n; cin >> n;
    rep(i,n){
        string s(100000,0);
        cin >> s;
        int temp = 0;
        int counter =-1 ;
        for(int k = 0;k<(int)s.size();k++){
            int now = int(s[k]-48);
            if(k == 0){temp = now;counter++;}
            else if(now != 0){
                temp = now;counter++;}
            if(now == 0){
                if(temp  == 9 || temp == 7)
                    counter%=4;
                else if(temp != 1&& temp != 7 && temp!= 9)
                    counter%=3;
                else if(temp == 1)
                    counter %=5;
                cout << ans[temp][counter];
                temp = 0;counter =-1;;
            }
        }
        cout << endl;
    }
    return 0;
}