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 <string>

using namespace std;

char m[][6] = {
  {},
  {5, '.', ',', '!', '?', ' '}, // 1
  {3, 'a', 'b', 'c'}, // 2
  {3, 'd', 'e', 'f'}, // 3
  {3, 'g', 'h', 'i'}, // 4
  {3, 'j', 'k', 'l'}, // 5
  {3, 'm', 'n', 'o'}, // 6
  {4, 'p', 'q', 'r', 's'}, // 7
  {3, 't', 'u', 'v'}, // 8
  {4, 'w', 'x', 'y', 'z'}, // 9
};

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

  while (N--) {
    string str;
    cin >> str;

    int s = 0, cnt = -1;
    for (int i=0; i<str.size(); i++) {
      int d = str[i] - '0';
      if (d == 0) {
        if (s != 0) { cout << m[s][ (cnt % m[s][0]) + 1 ]; }
        s = 0; cnt = -1;
      } else {
        s = d;
        cnt++;
      }
    }

    cout << endl;
  }

  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v),end()
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;

template<typename A,typename B> inline void chmin(A &a,B b){if(a>b) a=b;}
template<typename A,typename B> inline void chmax(A &a,B b){if(a<b) a=b;}
//-----------------------------------------------------------------------

string table[10]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

int n; cin>>n;
while(n--)
{
    string s; cin>>s;
    int cnt=0,idx;
    REP(i,s.size()){
        if(s[i]!='0'){
            cnt++;
            idx=s[i]-'0';
        } else{
            if(cnt>0) cout<<table[idx][(cnt-1)%table[idx].size()];
            cnt=0;
        }
    }
    cout<<endl;
}
}

C++: #include <bits/stdc++.h>
using namespace std;

int main(){
  string p[9]={".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
  string s;
  int n;
  cin>>n;
  while(n--){
    cin>>s;
    for(int i=0;i<(int)s.size();i++)
      if(s[i]=='0') s[i]=' ';
    stringstream ss(s);
    while(ss>>s){
      cout<<p[s[0]-'1'][(s.size()-1) % p[s[0]-'1'].size()];
    }
    cout<<endl;
  }

  return 0;
}

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

#define rep(i,n) for(int i=0; i<n; i++)

int main(){
	int n;
	int code;
	int num;
	char key[11][7] = {
			{},
			{'.',',','!','?',' '},
			{'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'},
	};

	std::cin >> n;
	std::string str;

	rep(i,n){
		code = 0;
		num = 0;
		std::cin >> str;
		rep(j,(int)str.size()){
			if(str[j] != '0'){
				num++;
			}else{
				if(j > 0 && str[j-1] != '0'){
					code = str[j-1]-'0';
					if(code == 1){
						std::cout << key[code][(num-1)%5] << std::flush;
					}else if(code == 7 || code == 9){
						std::cout << key[code][(num-1)%4] << std::flush;
					}else{
						std::cout << key[code][(num-1)%3] << std::flush;
					}
					code = 0;
					num = 0;
				}
			}
		}
		std::cout << std::endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<cstring>
#include<utility>
#include<set>
#include<stack>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX  999999
int main(){
    char ans[][10] = {
        {},
        {'.',',','!','?',' '},
        {'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; cin >> n;
    rep(i,n){
        string s(100000,0);
        cin >> s;
        int temp = 0;
        int counter =-1 ;
        for(int k = 0;k<s.size();k++){
            int now = int(s[k]-48);
            if(k == 0){temp = now;counter++;}
            else if(now != 0){
                temp = now;counter++;}
            if(now == 0){
                if(temp  == 9 || temp == 7)
                    counter%=4;
                else if(temp != 1&& temp != 7 && temp!= 9)
                    counter%=3;
                else if(temp == 1)
                    counter %=5;
                cout << ans[temp][counter];
                temp = 0;counter =-1;;
            }
        }
        cout << endl;
    }
}

C++: #include <iostream>
#include <string>
using namespace std;
int main(){
	string list[] = {
		" ",".,!? ","abc","def"
		,"ghi","jkl","mno"
		,"pqrs","tuv","wxyz"
	};
	string str,out;
	int times;
	cin >> times;
	for(int i =0 ;i<times;i++){
		cin >> str;
		char cur='1',cash='a';
		int count = 0,idx;
		int n = 0;
		while(n <str.size()){
			cur = str[n];

			if(cur == '0'){
					out +=list[idx][count%=list[idx].size()];
			}
			else if(cur ==cash){
				count +=1;
			}
			else{
				idx= (int)(cur - '0');
			}
			n++;
		}//?????????????????°???????????????
		cout << out << endl;
		out ="";
	}
		return 0;
}