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(){
  string s[9];
  s[0]=".,!?S";
  s[1]="abc";
  s[2]="def";
  s[3]="ghi";
  s[4]="jkl";
  s[5]="mno";
  s[6]="pqrs";
  s[7]="tuv";
  s[8]="wxyz";
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    string t;
    cin>>t;
    int c=0;
    for(int j=1;j<t.size();j++){
      if(t[j]=='0'&&t[j-1]!='0'){
	if(s[t[j-1]-'1'][(j-c-1)%s[t[j-1]-'1'].size()]=='S')cout<<" ";
	else cout<<s[t[j-1]-'1'][(j-c-1)%s[t[j-1]-'1'].size()];
	c=j+1;
      }
    }
    cout<<endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int check(int num,char c){
  if(c == '1')return num%5;
  if(c == '7' || c == '9')return num%4;
  else return num%3;
}

int main(){
  int n,i,j;
  string s;
  char b[10][5];
  char c = 'a';
  b[1][0]='.';
  b[1][1]=',';
  b[1][2]='!';
  b[1][3]='?';
  b[1][4]=' ';
  for(i=2;i<10;i++){
    for(j=0;j<3;j++){
      b[i][j]=c;
      c++;
    }
    if(i==7 || i==9){
      b[i][3]=c;
      c++;
    }
  }
  cin >> n;
  for(i=0;i<n;i++){
    cin >> s;
    j=0;
    while(j<s.size()){
      c = s[j];
      if(c=='0'){
        j++;
        continue;
      }
      int num=0;
      j++;
      while(s[j]==c){
        num++;
        j++;
      }
      num = check(num,c);
      cout << b[c-'0'][num];
    }
    cout << endl;
  }
  return 0;
}

C++: #include <iostream>
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)

using namespace std;

int main()
{
  char keitai[10][5] = {{'*', '*', '*', '*', '*'},
                        {'.', ',', '!', '?', ' '},
                        {'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', '*'},
  };
  string s;
  int x , c;
  char p;
  int n;
  cin >> n;
  cin.ignore();
  REP(k, n){
    getline(cin, s);
    x = c = 0;
    p = '\0';
    REP(i, s.size()){
      int j;
      j = s[i] - '0';
      if(j){
        if(x == j){
          if(keitai[j][c + 1] == '*'){
            c = 0;
            p = keitai[j][c];
          }else{
            c++;
            p = keitai[j][c];
          }
        }else{
          c = 0;
          p = keitai[j][c];
        }
      }else{
        if(p != '\0')
          cout << p;
        p = '\0';
      }
      x = j;
    }
    cout << endl;
  }
}

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

#define rep(i,j) for(int (i)=0;(i)<(j);++(i))

int main() {
    string code[9];
    code[0] = ".,!? ";
    code[1] = "abc";
    code[2] = "def";
    code[3] = "ghi";
    code[4] = "jkl";
    code[5] = "mno";
    code[6] = "pqrs";
    code[7] = "tuv";
    code[8] = "wxyz";
    int n;
    cin >> n;
    rep(i, n) {
        string c;
        cin >> c;
        int idx = -1, cnt = -1;
        rep(j, c.length()) {
            string t = "";
            t += c[j];
            int num = atoi(t.c_str());
            if (num == 0) {
                if (idx != -1 && cnt != -1) cout << code[idx][cnt];
                idx = -1;
                cnt = -1;
            }
            else {
                if (idx == -1 && cnt == -1) {
                    idx = num-1;
                    cnt = 0;
                }
                else {
                    cnt = (cnt+1)%code[idx].length();
                }
            }
        }
        cout << endl;
    }
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  string table[]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
  char str[1280];
  int a;
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>str;
    int r=0;
    char now='0';
    for(int i=0;str[i];i++){
            if(now!=str[i]){
                if(now!='0'){
		  cout<<table[now-'0'][(r-1)%table[now-'0'].size()];
                }
                r=1;
                now=str[i];
            }else r++;
    }
	    cout<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

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

using namespace std;

const int INF = 1000000000;
const double eps = 1e-8;

int main(void) {
  string tb[] = {"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
  int sz[]={0,5,3,3,3,3,3,4,3,4};
  int n;cin>>n;
  REP(i,n){
    string s;
    cin>>s;
    int cnt = 0;
    int ochar = 0;
    REP(j,s.size()){
      if(s[j]=='0'){
        if(ochar!=0)
          cout<<tb[ochar][cnt%sz[ochar]];
        ochar = 0;
        cnt=0;
      }else{
        if(ochar==(s[j]-'0'))
          cnt++;
        else{
          cnt=0;
          ochar=s[j]-'0';
        }
      }
    }
    cout<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long int lli;

string charset[10][5] = {
	{},
	{".", ",", "!", "?", " "},
	{"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"}
};
int loop[10] = {0, 5, 3, 3, 3, 3, 3, 4, 3, 4};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;
	for (int n = 0; n < N; n++){
		string s;
		cin >> s;

		int i = 0;
		int push = -1;
		string ans = "";
		while (i < s.length()){
			int num = stoi(s.substr(i, 1));
			if (num != 0){
				int thisnum = num;
				while (num != 0){
					push++;
					i++;
					num = stoi(s.substr(i, 1));
				}
				ans += charset[thisnum][push % loop[thisnum]];
				push = -1;
			}
			i++;
		}
		cout << ans << endl;
	}

	return 0;
}

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

int main(void){
  int n, i, cnt;
  string str, ans;
  char init;
  vector<string> mp{"", ".,!? ","abc","def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
  cin >> n;
  while(n--){
    cin >> str;
    cout << str << endl;
    ans = "";
    i = 0;
    while(i < str.length()){
      while(str[i] == '0'){
        i++;
      }
      if(i >= str.length()){
        break;
      }
      init = str[i];
      cnt = 0;
      while(i < str.length() and str[i] == init){
        i++;
        cnt++;
      }
      ans += mp[init - '0'][(cnt - 1) % mp[init - '0'].length()];
    }
    cout << ans << endl;
  }
  return 0;
}