Go: /*
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2006&lang=jp
Keitai Message
*/

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

// 標準入力を取得するScannerのインスタンスを作成
var scanner = bufio.NewScanner(os.Stdin)

// 標準入力で各行を読み込みstringとして返す
func readLine() string {
	if scanner.Scan() {
		return scanner.Text()
	}
	return ""
}

func main() {
	// 1: . , ! ? (スペース)
	// 2: a b c
	// 3: d e f
	// 4: g h i
	// 5: j k l
	// 6: m n o
	// 7: p q r s
	// 8: t u v
	// 9: w x y z
	// 0: 確定ボタン

	// 改行から空白区切りに変更
	scanner.Split(bufio.ScanWords)
	line, _ := strconv.Atoi(readLine()) // 5行標準入力が続く

	table := []string{
		"",      // 0 index調整ためダミーデータ
		".,!? ", // 1
		"abc",   // 2
		"def",   // 3
		"ghi",   // 4
		"jkl",   // 5
		"mno",   // 6
		"pqrs",  // 7
		"tuv",   // 8
		"wxyz"}  // 9

	// 5行分の標準入力を格納するsliceを作成する
	messages := make([]string, 0, line)

	// sliceに標準入力の内容を格納する
	for i := 0; i < line; i++ {
		messages = append(messages, readLine()) // messages=[20 220 222220 44033055505550666011011111090666077705550301110 000555555550000330000444000080000200004440000]
	}

	// 各行毎に解析する
	for _, message := range messages { // message=000555555550000330000444000080000200004440000
		// 0で分割する
		messageSlice := strings.Split(message, "0") // messageSlice=[   55555555    33    444    8    2    444    ]
		for _, word := range messageSlice {
			if word == "" {
				// NOP.
				// 0をセパレーターにしているので空文字がsliceに格納されてい箇所がある
				// 何もしない
			} else { // word=55555555
				// 一文字取り出しコード値をASCII文字に変換する
				ascii := string((word[0])) // word[0]=5

				// ASCII文字からintへ変換する(tableのindexになる)
				number, _ := strconv.Atoi(ascii)

				// 入力回数をカウントする
				count := len(word) // 5

				// 同じ数字を続けて入力すると変化する文字はループすることを考慮する
				for count > len(table[number]) { // 5 > 3
					count -= len(table[number]) // 2
				}

				// キー配列
				keys := table[number]                   //jkl
				fmt.Printf("%s", string(keys[count-1])) //k
			}
		}
		fmt.Println() // 改行
	}
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int n; cin >> n;
  rep(i, n) {
    string s; cin >> s;
    int n = s.size();

    string ans = "";
    vstr memo = {
      ".,!? ",
      "abc",
      "def",
      "ghi",
      "jkl",
      "mno",
      "pqrs",
      "tuv",
      "wxyz",
    };
    int prev = -1, x = -1;
    rep(i, n) {
      if (s[i] == '0') {
        if (x != -1) ans += memo[prev][x];
        x = -1, prev = -1;
      } else {
        int y = s[i] - '1';
        prev = y, x++;
        if (x >= memo[prev].size()) x = 0;
      }
    }
    cout << ans << '\n';
  }
}

C++: #include <iostream>

using namespace std;

int    nextInt()    { int d;      cin >> d;   return d;   }
string nextString() { string str; cin >> str; return str; }

string solve(string input) {
  string ret;

  char keys[][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 key_size[] = {
    -1, 5, 3, 3, 3, 3, 3, 4, 3, 4
  };
  
  char next;
  int idx = 0;
  for (int i = 0; i < input.size(); i++) {
    char c = input[i];
    if (c == '0') {
      ret += next;
      next = '\0';
      idx = 0;
    } else {
      next = keys[c - '0'][idx];
      idx = (idx + 1) % key_size[c - '0'];
    }
  }
  
  return ret;
}

int main() {
  int n = nextInt();
  for (int i = 0; i < n; i++) {
    string input = nextString();
    cout << solve(input) << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>

using namespace std;

#define INF 999999999

int main(){
	int N, i, j, pr, b, n, no[10]={1,5,3,3,3,3,3,4,3,4};
	string s;
	vector<string> c(10);
	c[0] = "a";
	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";
	
	cin >> N;
	for(i=0;i<N;i++){
		cin >> s;
		pr = 0;
		n = 0;
		//cout << s.size();
		for(j=0;j<s.size();j++){
			b = s[j] - '0';
			//cout << b;
			if(pr == b){
				n++;
			}
			else if(b==0){
				//cout << pr << n%no[pr] << endl;
				cout << c[pr][n%no[pr]];
			}
			else {
				n=0;
			}
			pr = b;
		}
		cout << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	char a[9][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 n,b=0,c=0,d=0;
	string s;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;b=d=c=0;
		char ss[100];
			for(int j=0;j<s.size();j++){
				if(s[j]=='0'&&c>0){
					if(s[j-1]=='1')d=(c-1)%5;
					else if(s[j-1]=='6'||s[j-1]=='8')d=(c-1)%4;
					else d=(c-1)%3;
					cout<<a[(int)(s[j-1]-'0')-1][d];
				c=0;
				}
				else c++;
				}
				cout<<endl;
	}
	return 0;
}

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

using namespace std;

int main(){
	int n; cin >> n;
	vector<string> button(10);
	button[1] = ".,!? ";
	button[2] = "abc";
	button[3] = "def";
	button[4] = "ghi";
	button[5] = "jkl";
	button[6] = "mno";
	button[7] = "pqrs";
	button[8] = "tuv";
	button[9] = "wxyz";
	for(int i = 0; i < n; ++i){
		string str; cin >> str;
		int acc = -1;
		int pre = 0;
		for(int j = 0; j < str.size(); ++j){
			if(str[j] == '0'){
				if(pre == 0) continue;
				int s = button[pre].size();
				char out = button[pre][acc % s];
				cout << out;
				acc = -1;
			}
			else{
				if(acc == -1){
					acc = 0;
					pre = str[j] - '0';
				}
				else{
					acc ++;
				}
			}

		}
		cout << endl;
	}
	return 0;
}