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 <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12

int main(void) {
  vector<vector<char>> c;
  c = {{' '},           {'.', ',', '!', '?', ' '},
       {'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 num;
  cin >> num;
  REP(s, num) {
    string n;
    cin >> n;

    int kind = -1, cnt = 0;
    REP(i, n.size()) {
      if (n[i] == '0') {
        if (kind != -1) {
          cnt = (cnt - 1) % c[kind].size();
          cout << c[kind][cnt];
        }
        kind = -1;
        cnt = 0;
      } else {
        kind = n[i] - '0';
        cnt++;
      }
    }
    cout << endl;
  }

  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
char c[10][10];
int main(void){
    c[1][0]='.';
    c[1][1]=',';
    c[1][2]='!';
    c[1][3]='?';
    c[1][4]=' ';
    char alpha='a';
    for(int i=2;i<=9;i++){
        int index=0;
        if(i==7|| i==9){
            while(index<4){
                c[i][index]=alpha;
                index++;
                alpha++;
            }
        }
        else{
            while(index<3){
                c[i][index]=alpha;
                index++;
                alpha++;
            }
        }
    }
    int n;
    string s;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        int cnt=0;
        char d='0';
        for(int i=0;i<s.length();i++){
            if(s[i]=='0'){
                if(d!='0'){
                    int x=d-'0';
                    if(x==7||x==9){
                        cout<<c[x][(cnt-1)%4];
                        cnt=0;
                        d='0';
                    }
                    else if(x==1){
                        cout<<c[x][(cnt-1)%5];
                        cnt=0;
                        d='0';
                    }
                    else{
                        cout<<c[x][(cnt-1)%3];
                        cnt=0;
                        d='0';
                    }
                }
            }
            else{
                d=s[i];
                cnt++;
            }
        }
        cout<<endl;
    }
    return 0;
}

C++: #include <iostream>
#include <cstring>
#include <cstdlib>
using namespace std;
int main()
{
	int n, i, j, k, c, d, x;
	char s[1025], t[10][6] = {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> s;
		for (j = x = 0, d = 0; j < strlen(s); j++, d = c)
		{
			c = s[j] - '0';
			if (c == 0 && d != 0)
				cout << t[d-1][x%strlen(t[d-1])];
			else if (d == c)
				x++;
			else
				x = 0;
		}
		cout << endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

int n;

char InputEnter(int num, int no) {
    char res;
    if(num == 1) {
        no %= 5;
        if(no == 0) res = '.';
        else if(no == 1) res = ',';
        else if(no == 2) res = '!';
        else if(no == 3) res ='?';
        else res = ' ';
    }else if(num == 2) {
        no %= 3;
        if(no == 0) res = 'a';
        else if(no == 1) res = 'b';
        else res = 'c';
    }else if(num == 3) {
        no %= 3;
        if(no == 0) res = 'd';
        else if(no == 1) res = 'e';
        else res = 'f';
    }else if(num == 4) {
        no %= 3;
        if(no == 0) res = 'g';
        else if(no == 1) res = 'h';
        else res = 'i';
    }else if(num == 5) {
        no %= 3;
        if(no == 0) res = 'j';
        else if(no == 1) res = 'k';
        else res = 'l';
    }else if(num == 6) {
        no %= 3;
        if(no == 0) res = 'm';
        else if(no == 1) res = 'n';
        else res = 'o';
    }else if(num == 7) {
        no %= 4;
        if(no == 0) res = 'p';
        else if(no == 1) res = 'q';
        else if(no == 2) res = 'r';
        else res = 's';
    }else if(num == 8) {
        no %= 3;
        if(no == 0) res = 't';
        else if(no == 1) res = 'u';
        else res = 'v';
    }else if(num == 9) {
        no %= 4;
        if(no == 0) res = 'w';
        else if(no == 1) res = 'x';
        else if(no == 2) res = 'y';
        else res = 'z';
    }
    return res;
}

int main() {
    cin >> n;
    while(n--) {
        string s; cin >> s;
        int slen = s.length();
        vector<char> ans;
        int cc = 0;
        int cno = 0;
        for(int i = 0; i < slen; ++i) {
            int ch = s[i] - '0';
            if(ch == 0) {
                if(cc == 0) continue;
                ans.emplace_back(InputEnter(cno, cc-1));
                cc = 0;
            }else {
                cno = ch;
                cc++;
            }
        }
        for(int i = 0; i < (int)ans.size(); ++i) {
            cout << ans[i];
        }
        cout << endl;
    }
}

C++: #include <string>
#include <iostream>

using namespace std;

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

int main()
{
	int n; scanf("%d", &n);

	for (int i = 0; i < n; i++)
	{
		string S; cin >> S;

		int count_ = 0;

		for (int i = 0; i < S.size(); i++)
		{
			if (S[i] == '0')
			{
				if (count_ != 0)
				{
					cout << R[S[i - 1] - 49][(count_ - 1) % R[S[i - 1] - 49].size()]; count_ = 0;
				}
			}
			else
			{
				count_++;
			}
		}

		cout << endl;
	}

	return 0;
}

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

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

string solve(string in){
  string res="";
  int c=0;
  int n_in=0;
  for(int i=0;i<in.size();i++){
    int t_in=in[i]-'0';
    if(t_in==0){
      if(n_in!=0){
        res+=push[n_in][(c%push[n_in].size())];
      }
      n_in=0;
      c=0;
    }else{
      if(t_in==n_in){
        c++;
      }else{
        c=0;
	n_in=t_in;
      }
    }
  }
  return res;
}



int main(){
  string in;
  while(cin>>in){
    string ans=solve(in);
    if(ans.size()!=0){
      cout<<ans<<endl;
    }
  }
}