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 FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

int main(void) {
	int n;
	string s;

	cin >> n;
	FOR(i, 1, n) {
		cin >> s;
		int count = 0;
		int now = 0;
		FOR(t, 0, s.size() - 1) {
			if (s[t] == '0') {
				if (now == 1) {
					switch (count % 5) {
					case 0:
						cout << " ";
						break;
					case 1:
						cout << ".";
						break;
					case 2:
						cout << ",";
						break;
					case 3:
						cout << "!";
						break;
					case 4:
						cout << "?";
						break;
					}
				}
				else if (now == 7) {
					switch (count % 4) {
					case 0:
						cout << "s";
						break;
					case 1:
						cout << "p";
						break;
					case 2:
						cout << "q";
						break;
					case 3:
						cout << "r";
						break;
					}
				}
				else if (now == 9) {
					switch (count % 4) {
					case 0:
						cout << "z";
						break;
					case 1:
						cout << "w";
						break;
					case 2:
						cout << "x";
						break;
					case 3:
						cout << "y";
						break;
					}
				}
				else if (now == 2) {
					switch (count % 3) {
					case 0:
						cout << "c";
						break;
					case 1:
						cout << "a";
						break;
					case 2:
						cout << "b";
						break;
					}
				}
				else if (now == 3) {
					switch (count % 3) {
					case 0:
						cout << "f";
						break;
					case 1:
						cout << "d";
						break;
					case 2:
						cout << "e";
						break;
					}
				}
				else if (now == 4) {
					switch (count % 3) {
					case 0:
						cout << "i";
						break;
					case 1:
						cout << "g";
						break;
					case 2:
						cout << "h";
						break;
					}
				}
				else if (now == 5) {
					switch (count % 3) {
					case 0:
						cout << "l";
						break;
					case 1:
						cout << "j";
						break;
					case 2:
						cout << "k";
						break;
					}
				}
				else if (now == 6) {
					switch (count % 3) {
					case 0:
						cout << "o";
						break;
					case 1:
						cout << "m";
						break;
					case 2:
						cout << "n";
						break;
					}
				}
				else if (now == 8) {
					switch (count % 3) {
					case 0:
						cout << "v";
						break;
					case 1:
						cout << "t";
						break;
					case 2:
						cout << "u";
						break;
					}
				}

				now = 0;
				count = 0;
			}
			else {
				now = s[t] - '0';
				count++;
			}
		}
		cout << endl;
	}
}

C++: #include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
vector<vector<char> > c(10, vector<char>(5));
int main()
{
  c[1][0] = '.';c[1][1] = ',';c[1][2] = '!';c[1][3] = '?';c[1][4] = ' ';
  FOR(i,0,3) c[2][i] = 'a' + i;
  FOR(i,0,3) c[3][i] = 'd' + i;
  FOR(i,0,3) c[4][i] = 'g' + i;
  FOR(i,0,3) c[5][i] = 'j' + i;
  FOR(i,0,3) c[6][i] = 'm' + i;
  FOR(i,0,4) c[7][i] = 'p' + i;
  FOR(i,0,3) c[8][i] = 't' + i;
  FOR(i,0,4) c[9][i] = 'w' + i;
  int n;
  cin >> n;
  while(n--) {
    string s;
    cin >> s;
    int cnt = 0;
    char now;
    string ans = "";
    FOR(i,0,s.length()) {
      if(s[i] == '0' && now != '0') {
        cnt--;
        if(now == '1') cnt %= 5;
        else if(now == '7' || now == '9') cnt %= 4;
        else cnt %= 3;
        ans += c[now-'0'][cnt];
        now = '0';
        cnt = 0;
      } else if(s[i] != '0'){
        now = s[i];
        cnt++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

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

char p(int n, int times) {
    return s[n][(times - 1) % (int)s[n].size()];
}

int main() {
    int N;
    cin >> N;
    string msg;
    while (N --) {
        cin >> msg;
        string t = "";
        for (int i=0; i<(int)msg.size(); ++i) {
            if (msg[i] == '0') {
                if (t != "") {
                    cout << p(t[0] - '0', t.size());
                    t = "";
                }
            } else {
                t += msg[i];
            }
        }
        cout << endl;
    }
    return 0;
}

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

int main() {
	int n;
	vector<vector<char>>boad(10);
	boad[1] = { '.',',','!','?',' ' };
	char c = 'a';
	for (int i = 2; i < 10; ++i) {
		if (i != 7 && i != 9) {
			for (int j = 0; j < 3; ++j) {
				boad[i].push_back(c++);
			}
		}
		else for (int j = 0; j < 4; ++j)boad[i].push_back(c++);
	}
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		char b,pre='0';
		int count = 1;
		int sup = s.length();
		for (int l = 0; l < sup; ++l) {
			b = s[l];
			if (pre != b) {
				int num = pre - '0';
				if (num) printf("%c", boad[num][(count - 1) % boad[num].size()]);
				count = 1;
				pre = b;
			}
			else count++;
		}
		printf("\n");
	}
}