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(){
	int n;
	string in, out;
	vector<string> trans(10);
	trans[0] = "";
	trans[1] = ".,!? ";		trans[2] = "abc";	trans[3] = "def";
	trans[4] = "ghi";		trans[5] = "jkl";	trans[6] = "mno";
	trans[7] = "pqrs";		trans[8] = "tuv";	trans[9] = "wxyz";
	cin >> n;
	for( int k=0; k<n; k++ ){
		cin >> in;
		out = "";
		int cnt=0;
		for( int i=0; i<in.length(); i++ ){
			if( in[i] == '0' ){
				if( cnt > 0 ){
//					cout << "out:trans[" << in[i-1] << "][" << cnt << "%trans[" << in[i-1] << "].length]" << endl;
					out += trans[in[i-1]-'0'][(cnt-1)%trans[in[i-1]-'0'].length()];
					cnt = 0;
				}
			}else	cnt++;
		}
		cout << out << endl;
	}
	return 0;
}

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

#define int long long
#define DEBUG(x) cerr <<#x<<":"<<x<<endl;
#define DEBUG2(x, y) cerr <<#x<<":"<<x<<" "<<#y<<":"<<y<<endl;
#define DEBUG3(x, y, z) cerr <<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl;
#define DEBUGVC(x) cerr <<#x<<": "; for(auto a:x) cerr << a <<" "; cerr << endl;
#define DEBUGMP(x) cerr <<#x<<":"<<endl; for(auto a:x) cerr << a.first <<" "<< a.second << endl;
#define MAX_N (1000006)
#define INF (1LL << 60)
const int MOD = (int)1e9+7;


signed main() {
    int T;
    cin >> T;

    vector<string> vcs = {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};

    for(int t=0; t<T; t++) {
        string s;
        cin >> s;

        int idx = -1;
        int num = 0;
        bool flag = false;
        for(int i=0; i<s.length(); i++){
            //cout << i <<" "<< s[i] <<" "<< idx << endl;
            if (s[i] == '0') {
                //cout << i <<" num:"<< num <<" idx:"<< idx <<" flag:"<< flag << endl;
                if (!flag) cout << "";
                else cout << vcs[num-1][idx];
                //cout << endl;
                idx = -1;
                flag = false;
            } else {
                flag = true;
                num = s[i] - '0';
                idx = (idx+1)%vcs[num-1].length();
                //cout << vcs[num-1][idx] << endl;
            }
            //cout << s[i] << endl;
        }
        cout << endl;
    }
}

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

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

string solve(){
  string t = "";

  int key=0, cnt=0;
  for(int i=0; i<(int)s.size(); i++){
    int S = s[i] - '0';
    if(S==0){
      if(key!=0){
        cnt--;
        int len=a[key].size();
        t.push_back(a[key][cnt%len]);
      }
      cnt=key=0;
    } else if(key==S){
      cnt++;
    } else {
      key=S;
      cnt=1;
    }
  }
  return t;
}

int main(){
  int n;
  cin >> n;
  while(n--){
    cin >> s;
    cout << solve() << endl;
  }
  return 0;
}

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

#define rep(i,a,b) for(int i=a;i<b;i++)

void b(int a,int count){
  if(a == 1){
    if(count%5==1) cout <<".";
    else if(count%5==2) cout <<",";
    else if(count%5==3) cout <<"!";
    else if(count%5==0) cout <<" ";

  }
  else if(a == 2){
    if(count%3==1) cout <<"a";
    else if(count%3==2) cout <<"b";
    else if(count%3==0) cout <<"c";
  }
  else if(a == 3){
    if(count%3==1) cout <<"d";
    else if(count%3==2) cout <<"e";
    else if(count%3==0) cout <<"f";
  }
  else if(a == 4){
    if(count%3==1) cout <<"g";
    else if(count%3==2) cout <<"h";
    else if(count%3==0) cout <<"i";
  }
  else if(a == 5){
    if(count%3==1) cout <<"j";
    else if(count%3==2) cout <<"k";
    else if(count%3==0) cout <<"l";
  }
  else if(a == 6){
    if(count%3==1) cout <<"m";
    else if(count%3==2) cout <<"n";
    else if(count%3==0) cout <<"o";
  }
  else if(a == 7){
    if(count%4==1) cout <<"p";
    else if(count%4==2) cout <<"q";
    else if(count%4==3) cout <<"r";
    else if(count%4==0) cout <<"s";
  }
  else if(a == 8){
    if(count%3==1) cout <<"t";
    else if(count%3==2) cout <<"u";
    else if(count%3==0) cout <<"v";
  }
  else if(a == 9){
    if(count%4==1) cout <<"w";
    else if(count%4==2) cout <<"x";
    else if(count%4==3) cout <<"y";
    else if(count%4==0) cout <<"z";
  }
  return;
}


int main(){

  int n;
  cin >> n;

  rep(i,0,n){
    string s;
    cin >> s;


    char pre[] = "0\0";
    pre[0]=s[0];
    int count = 0;
    rep(i,0,s.size()){
      if(pre[0] == s[i]){
	count++;
      }
      else{
	int bo = atoi(pre);
	b( bo,count);
	count=1;
	pre[0]=s[i];
      }
    }
    cout << endl;
  }
  return 0;
}

C++: #include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

string moji[10];

int main(void) {
    int n;
    moji[1] = ".,!? ";
    moji[2] = "abc";
    moji[3] = "def";
    moji[4] = "ghi";
    moji[5] = "jkl";
    moji[6] = "mno";
    moji[7] = "pqrs";
    moji[8] = "tuv";
    moji[9] = "wxyz";
    cin >> n;
    while (n--) {
        string s;
        cin >> s;
        string ans;
        for (int i = 0; i < s.size(); i++) {
            int num = 0;
            while (s[i] != '0') {
                i++;
                num++;
            }
            if (num == 0) continue;
            int tmp = s[i-1] - '0';
            if (tmp == 1) num = (num-1) % 5;
            else if (tmp == 7 || tmp == 9) num = (num-1) % 4;
            else num = (num-1) % 3;
            ans += moji[tmp][num];
        }
        cout << ans << endl;
    }
    return 0;
}