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(){
  int n, b[2]={0};
  cin >> n;
  while(n--){
    string s;
    cin >> s;
    for(int i=0; i<s.length(); i++){
      if(s[i]=='0'){
	if(b[0] != 0){
	  int a = b[0]-'0';
	  if(a==1){
	    b[1]%=5;
	    if(b[1]==0)
	      cout << " ";
	    else if(b[1]==1)
	      cout << ".";
	    else if(b[1]==2)
	      cout << ",";
	    else if(b[1]==3)
	      cout << "!";
	    else if(b[1]==4)
	      cout << "?";
	  }
	  else if(a==2 || a==3 || a==4 || a==5 || a==6 || a==8){
	    b[1]%=3;
	    if(b[1]==0)
	      b[1] = 3;
	    if(a==8)
	      b[1]++;
	    char c = b[1]+'a'-1+3*(b[0]-'0'-2);
	    cout << c;
	  }
	  else if(a==7 || a==9){
	    b[1]%=4;
	    if(b[1]==0)
	      b[1] = 4;
	    if(a==9)
	      b[1]++;
	    char c = b[1]+'a'-1+3*(b[0]-'0'-2);
	    cout << c;
	  }
	}
	b[0]=0;
	b[1]=0;
      }
      else{
	b[0] = s[i];
	b[1]++;
      }
    }
    cout << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
    int t;
    cin >> t;
    vector<string> c(10);
    c[1] = ".,!? ";
    c[2] = "abc";
    c[3] = "def";
    c[4] = "ghi";
    c[5] = "jkl";
    c[6] = "mno";
    c[7] = "pqrs";
    c[8] = "tuv";
    c[9] = "wxyz";
    while(t--){
        string s;
        cin >> s;
        string ans = "";
        int t = 0;
        int n = s.size();
        for(int i = 0; i < n; i++){
            if(s[i] > '0'){
                t++;
            }else{
                if(t){
                    int m = c[s[i-1]-'0'].size();
                    ans += c[s[i-1]-'0'][(t+m-1)%m];
                    t = 0;
                }
            }
        }
        cout << ans << endl;
    }
}

C++: #define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
#define  rep(i,n) for(int i=0;i<(n);i++)
#define  REP(i,a,n) for(int i=a;i<(n);i++)
#define  rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define  VI	vector<int>
#define	 VS vector<string>
#define  all(a) (a).begin(),(a).end()
#define  debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int INF=1000000;
char fi[101][101];
int d[21][21];
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int N,M;
int sx,sy;
int gx,gy;
int w,h;
int ans;

int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int MAX_V=100;
const int MAX_N=100;
char o[3]={'+','-','*'};
#define md 1000003

int dp[353][353]={0};
int bow[353][353]={0};


int main(){
	
	string s;
	
	while(cin>>s){
		vector<string> p(10);
		p[1]=".,!? ";
		p[2]="abc";
		p[3]="def";
		p[4]="ghi";
		p[5]="jkl";
		p[6]="mno";
		p[7]="pqrs";
		p[8]="tuv";
		p[9]="wxyz";
		bool f=false;
		char c='0';
		int count=0;
		string a="";
		rep(i,s.size()){
			if(s[i]=='0'){
				if(f){
				if(c=='1'){
					count=(count-1)%5;
				}
				else if(c=='7'||c=='9'){
					count=(count-1)%4;
				}
				else{
					count=(count-1)%3;
				}
				a+=p[c-'0'][count];
				f=false;
				count=0;
				c='0';
				}
			}
			else{
				f=true;
				if(c!=s[i]){
					c=s[i];
					count=1;
				}
				else
					count++;
				
			}
			
		}
		cout<<a<<endl;
	}
	
}

C++: #include <iostream>
#include <cstdio>
#include <stack>
#include <queue>

#define MAX 2048

using namespace std;

int main(void) {
	int n, num = 0, count = 0;
	char nums[MAX];
	scanf("%d", &n);
	while(n--) {
		scanf("%s", nums);
		for(int i = 0; nums[i] != '\0'; i++) {
			if(nums[i] == '0') {
				if(num >= 2 && num <= 6) {
					printf("%c", (num - 2) * 3 + ((count + 2) % 3) + 'a');
				} else if(num == 7) {
					printf("%c", (count + 3) % 4 + 'p');
				} else if(num == 8) {
					printf("%c", (count + 2) % 3 + 't');
				} else if(num == 9) {
					printf("%c", (count + 3) % 4 + 'w');
				} else if(num == 1) {
					switch((count + 4) % 5) {
					case 0: printf("."); break;
					case 1: printf(","); break;
					case 2: printf("!"); break;
					case 3: printf("?"); break;
					case 4: printf(" "); break;
					}
				} else {
					printf("");
				}
				num = 0;
				count = 0;
			}
			else if(nums[i] == num + '0') {
				count++;
			} else {
				num = nums[i] - '0';
				count = 1;
			}
		}
		printf("\n");
	}
	return 0;
}

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

typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define DECIM8  fixed<<setprecision(8) 
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

using namespace std;
int main(void)
{
  string lib[10]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
  int t;
  cin >> t;
  for(;t--;){
    string input;
    cin >> input;
    char last='0';
    int ren=0;
    REP(i,SZ(input)){
      if(input[i]==last) ++ren;
      else{
	if(last-'0')
	  cout << lib[last-'0'][ren%SZ(lib[last-'0'])];
	ren=0;
      }
      last=input[i];
    }
    cout << endl;
  }
  return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

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


int main()
{

    int n;
    cin >> n;
        string s;
    getline(cin, s);
    while(n--)
    {
        getline(cin, s);
        int bnum = 0;
        int pushnum = 0;

        //cout << s << endl;
        //cout << s.size() << endl;

        REP(s.size() - 1)
        {
            if(s[i] == '0' && pushnum > 0)
            {
                cout << button[bnum][(pushnum) % button[bnum].size() - 1];
                pushnum = 0;
                bnum = 0;
            }
            if(s[i] != '0'){ pushnum++; bnum = s[i] - '0';}

        }
        cout << endl;
    }
    return 0;
}