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> // C++の入出力
#include <stdio.h> // C の入出力
#include <algorithm> // sort などのアルゴリズム
#include <string.h> // C の文字列用
#include <ctype.h> // C の文字種用
#include <string> // C++の文字列
#include <math.h>
#include <sstream>

using namespace std;
int main(void){
    int n;
    cin>>n;
    string out1=".,!? ";
    string out2="abc";
    string out3="def";
    string out4="ghi";
    string out5="jkl";
    string out6="mno";
    string out7="pqrs";
    string out8="tuv";
    string out9="wxyz";
    for(int s=0;s<n;s++){
        string in;
        cin>>in;
        int cnt=0;
        for(int i=0;i<in.length();i++){
            switch (in[i]-'0') {
                case 0:
                    switch (in[i-1]-'0') {
                        case 1:
                            if(cnt<=5)cout<<out1[cnt-1];
                            else cout<<out1[cnt%5-1];
                            break;
                        case 2:
                            if(cnt<=3)cout<<out2[cnt-1];
                            else cout<<out2[cnt%3-1];
                            break;
                        case 3:
                            if(cnt<=3)cout<<out3[cnt-1];
                            else cout<<out3[cnt%3-1];
                            break;
                        case 4:
                            if(cnt<=3)cout<<out4[cnt-1];
                            else cout<<out4[cnt%3-1];
                            break;
                        case 5:
                            if(cnt<=3)cout<<out5[cnt-1];
                            else cout<<out5[cnt%3-1];
                            break;
                        case 6:
                            if(cnt<=3)cout<<out6[cnt-1];
                            else cout<<out6[cnt%3-1];
                            break;
                        case 7:
                            if(cnt<=4)cout<<out7[cnt-1];
                            else cout<<out7[cnt%4-1];
                            break;
                        case 8:
                            if(cnt<=3)cout<<out8[cnt-1];
                            else cout<<out8[cnt%3-1];
                            break;
                        case 9:
                            if(cnt<=4)cout<<out9[cnt-1];
                            else cout<<out9[cnt%4-1];
                            break;
                        case 0:
                            break;
                    }
                    cnt=0;
                    break;
                default:
                    cnt++;
                    break;
            }
        }
        if(in=="0")cout<<"";
        else cout<<endl;
    }
    return 0;
}

C++: #include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> pii;

int main()
{
  char str[100000]={};
  char moji[10][6]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
  int i;
  int n;

  cin>>n;
  rep(i,n){
    cin>>str;
    int len=strlen(str);
    int j=0;
    while(j<len){
      int num=0;
      while(str[j]!='0'){
	j++;
	num++;
      }
      if(j==0){
	j++;
	continue;
      }
      a=str[j-1]-'0';
      if(a==1)
	cout<<moji[1][(num-1)%5];
      else if((a>1 && a<7)|| a==8)
	cout<<moji[a][(num-1)%3];
      else if(a==7 || a==9)
	cout<<moji[a][(num-1)%4];
      j++;
    }
    cout<<endl;
  }
}

C++: #include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using hset = unordered_set<T>;
template<class Key, class T> using hmap = unordered_map<Key, T>;

int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
vector<vector<char> > phone = {
    {'\0'},
    {' ', '.', ',', '!', '?'},
    {'c', 'a', 'b'},
    {'f', 'd', 'e'},
    {'i', 'g', 'h'},
    {'l', 'j', 'k'},
    {'o', 'm', 'n'},
    {'s', 'p', 'q', 'r'},
    {'v', 't', 'u'},
    {'z', 'w', 'x', 'y'}
};

int main() {
    int n; cin >> n;
    string s;
    for (int i = 0; i < n; i++) {
        cin >> s;
        int k = 0, kl = 0;
        for (char c : s) {
            if (c - '0' == 0) {
                cout << phone[kl][k];
                k = 0;
                kl = 0;
            } else {
                kl = c - '0';
                k = (k+1) % phone[kl].size();
            }
        }
        cout << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<climits>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

int main() {
    int n; cin >> n;
    while (n--) {
        string s; cin >> s;
        char key = s[0], befkey = s[0];
        int c = 0;
        string table[10] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
        rrep(i, 1, s.size()) {
            key = s[i];
            if (key == '0' && befkey != '0') cout << table[befkey - '0'][c];
            if (key == befkey) {c++; if (table[befkey - '0'][c] == '\0') c = 0;}
            else c = 0;
            befkey = key;
        }
        cout << endl;
    }
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <string.h>

char data[10][6] = {
    "*",
    ".,!? ",
    "abc",
    "def",
    "ghi",
    "jkl",
    "mno",
    "pqrs",
    "tuv",
    "wxyz"
};

int data_len[10] = {1,5,3,3,3,3,3,4,3,4};

char out[256][2048],answer[256][2048];

int main(void){
    int k,c;
    scanf("%d",&c);
    for(k=0;k<c;k++){
      int i,j=0,count=-1,length,num,flag=0;
      char input[2048],input_num[2];
      char now;
      scanf("%s",input);
      length = strlen(input);
      input_num[1]='\0';
      now = input[0];
      for(i=0;;i++){
        if(input[i]=='\0') break;
        if(now==input[i]) count++;
        else{
          input_num[0] = now;
          out[k][j] = data[atoi(input_num)][count%data_len[atoi(input_num)]];
          j++;
          count = -1;
          now = input[i];
          i--;
        }
      }
      j = 0;
      for(i=0;i<strlen(out[k]);i++){
        if(out[k][i]!='*'){
          answer[k][j] = out[k][i];
          j++;
      }
      }
    }
    for(k=0;k<c;k++){
        printf("%s\n",answer[k]);
    }
    return 0;
}