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 <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
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(){
	int N;
	cin >> N;
	vector<string> ansvec;
	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++;
		}
		ansvec.push_back(ans);
	}

	for (auto it = ansvec.begin(); it != ansvec.end(); it++){
		cout << *it << endl;
	}
	return 0;
}

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

void strplus(string& s, int nn, int c)
{
	switch (nn) {
	case 0:
		break;
	case 1:
		switch (c % 5) {
		case 0:
			s += ".";
			break;
		case 1:
			s += ",";
			break;
		case 2:
			s += "!";
			break;
		case 3:
			s += "?";
			break;
		case 4:
			s += " ";
			break;
		}
		break;
	case 2:
		switch (c % 3) {
		case 0:
			s += "a";
			break;
		case 1:
			s += "b";
			break;
		case 2:
			s += "c";
			break;
		}
		break;
	case 3:
		switch (c % 3) {
		case 0:
			s += "d";
			break;
		case 1:
			s += "e";
			break;
		case 2:
			s += "f";
			break;
		}
		break;
	case 4:
		switch (c % 3) {
		case 0:
			s += "g";
			break;
		case 1:
			s += "h";
			break;
		case 2:
			s += "i";
			break;
		}
		break;
	case 5:
		switch (c % 3) {
		case 0:
			s += "j";
			break;
		case 1:
			s += "k";
			break;
		case 2:
			s += "l";
			break;
		}
		break;
	case 6:
		switch (c % 3) {
		case 0:
			s += "m";
			break;
		case 1:
			s += "n";
			break;
		case 2:
			s += "o";
			break;
		}
		break;
	case 7:
		switch (c % 4) {
		case 0:
			s += "p";
			break;
		case 1:
			s += "q";
			break;
		case 2:
			s += "r";
			break;
		case 3:
			s += "s";
			break;
		}
		break;
	case 8:
		switch (c % 3) {
		case 0:
			s += "t";
			break;
		case 1:
			s += "u";
			break;
		case 2:
			s += "v";
			break;
		}
		break;
	case 9:
		switch (c % 4) {
		case 0:
			s += "w";
			break;
		case 1:
			s += "x";
			break;
		case 2:
			s += "y";
			break;
		case 3:
			s += "z";
			break;
		}
		break;
	}
}

int main()
{
	int n;
	cin >> n;

	for (int i = 0; i < n; i++) {
		string str;
		string temp;

		cin >> temp;

		int nownum = 0;
		int count = 0;

		for (unsigned int j = 0; j < temp.size(); j++) {
			if (stoi(temp.substr(j, 1)) == 0) {
				strplus(str, nownum, count);
				nownum = 0;
			}
			else {
				if (nownum == stoi(temp.substr(j, 1))) {
					count++;
				}
				else {
					nownum = stoi(temp.substr(j, 1));
					count = 0;
				}
			}
		}

		cout << str << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  char m[9][5]={{'.',',','!','?',' '},
		{'a','b','c','1','1'},
		{'d','e','f','1','1'},
		{'g','h','i','1','1'},
		{'j','k','l','1','1'},
		{'m','n','o','1','1'},
		{'p','q','r','s','1'},
		{'t','u','v','1','1'},
		{'w','x','y','z','1'}};

  int a,count=0,c[100],d;
  char b[100][1024];
  cin>>a;
  for(int i=0;i<a;i++){
    scanf("%s",b[i]);
    c[i]=strlen(b[i]);
    for(int j=0;j<c[i];j++){
      if(b[i][j]!='0')count++;
      else
	if(b[i][j-1]!=0){
	  d=(int)(b[i][j-1])-48;

	  if(d==1)
	    if(count%5!=0)
	      cout<<m[d-1][count%5-1];
	    else cout<<m[d-1][4];

	  else if(d==7 || d==9)
	    if(count%4!=0)
	      cout<<m[d-1][count%4-1];
	    else cout<<m[d-1][3];

	  else
	    if(count%3!=0)
	      cout<<m[d-1][count%3-1];
	    else cout<<m[d-1][2]; 
	  count=0;
	}
    }
    cout<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
using namespace std;

char KeitaiKey[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;
string input;
stack<int> bt;

void init(){
  while(!bt.empty()) bt.pop();
}

int main(void){
  cin >> N;
  for(int i = 0; i < N; i++){
    init();
    cin >> input;
    for(int j = 0; j < input.size(); j++){
      if(input[j] == '0' && !bt.empty()){
        int nowbt = bt.top()  - 1;
        int size = bt.size();
        if(nowbt == 7 || nowbt == 9){
          if(size > 4) size = size % 4 - 1;
          else size--;
          cout << KeitaiKey[nowbt][size];
        }else if(nowbt == 0){
          if(size > 5) size = size % 5 - 1;
          else size--;
          cout << KeitaiKey[nowbt][size];
        }else{
          if(size > 3) size = size % 3 - 1;
          else size--;
          cout << KeitaiKey[nowbt][size];
        }
        init();
      }else if(input[j] != '0'){
        bt.push(input[j] - '0') ;
      }
    }
    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[40];
			for(int j=0;j<s.size();j++){
				if(s[j]=='0'&&c>0){
					if(s[j-1]=='1')d=c%5-1;
					else if(s[j-1]=='6'||s[j-1]=='8')d=c%4-1;
					else d=c%3-1;
					cout<<a[(int)(s[j-1]-'0'-1)][d];
				c=0;
				}
				else c++;
				}
				cout<<endl;
	}
	return 0;
}