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>

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

int main(){

  int N;

  std::cin >> N;

  //??\????????\???????????°??????????????????????????¨???????????¨???????????????
  while(N){
    int row = 0;
    int count = -1;
  
    std::string str;
    std::cin >> str;

    for(int i = 0; i < (int)str.size(); i++){
      int num = str[i] - '0'; //???'??°???' - '0'??? ??§????????¨???????????°?????????int ?????????(ex: '1'-'0' = 1)

      if(num != 0){
	row = num;
	count++;
      }else{

	if(row != 0) //?????????0?????´???????°?????????????
	  std::cout << key[row][ (count % key[row][0]) + 1 ]; 
	
	row = 0;
	count = -1;
	/*??????????????§???????????????count???0????????????????????????key??????????????????cout%key[row][0]????????????????????¨
	  5550???????????????????????\?????¨???????????????0????????£?????????????????¬??????3????????£????????????????????¨????????????????????????*/
      }

    }

    std::cout << std::endl;

    N--;
    
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
 string a[9] = {".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
 int n;
 cin >> n;
 for(int k=0; k<n; k++){
   string s;
   cin >> s;
   for(int i=0; i<(int)s.size(); i++){
     char c = s[i];
     int count = 0;
     for(i=i+1; i<(int)s.size(); i++){
       if(s[i] != c) break;
       count++;
    }
    i--;
    if(c=='0') continue;
    int num = c-'0'-1;
    int tmp = count % a[num].size();
    cout << a[num][tmp];
    }
    cout << endl;
 }
 return 0;
}

C++: #include<cstdio>
int main(){
	char C[10][6]={{},{'.',',','!','?',' ', 5 },{'a','b','c', 0 , 0 , 3 },{'d','e','f', 0 , 0 , 3 },{'g','h','i', 0 , 0 , 3 },{'j','k','l', 0 , 0 , 3 },{'m','n','o', 0 , 0 , 3 },{'p','q','r','s', 0 , 4 },{'t','u','v', 0 , 0 , 3 },{'w','x','y','z', 0 , 4 }},s[1025],c;
	int n,i,p;
	scanf("%d",&n);
	for(i=n;p=-1,scanf("%s",s),i;puts(""),--i){
		for(n=0;s[n];++n)
			(s[n]-48)?
				p++
			:
				p=-1,c=0,!c?printf("%c",C[s[n]-48][p%C[s[n]-48][5]]):0;

	}
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[1080], b[1080];
int n, m;

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

char _str[10800];
void output(int val, int cnt){
	if(val == 0)return;
	cout << button[val][(cnt-1) % button[val].size()];
}


int main(){
	while(~scanf(" %s", _str)){
		str = _str;
		int val = 0;
		int cnt = 0;
		for(int i = 0;i < str.size();i++){
			if(str[i] == '0'){
				output(val, cnt);
				val = cnt = 0;
			}
			else{
				val = str[i] - '0';
				cnt++;
			}
		}
		output(val, cnt);
		cout << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  V<string> c(10);
  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";
  int q; cin >> q;
  while (q--) {
    string s; cin >> s;
    int n = s.size();
    string res;
    char curr = 0;
    int j = 0;
    for (int i = 0; i < n; ++i) {
      if (s[i] == '0') {
        if (curr) res += curr;
        curr = 0;
        j = 0;
      } else {
        curr = c[s[i] - '0'][j++ % c[s[i] - '0'].size()];
      }
    }
    cout << res << '\n';
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string str,one=".,!? ",ans;
		cin>>str;
		for(int j=0,co=0,num=0;j<=str.size();j++){
			if(num==str[j]-'0')co++;
			else{
				if(num==1)ans+=one[co%5];
				else if(num==7)ans+=co%4+'p';
				else if(num==8)ans+=co%3+'t';
				else if(num==9)ans+=co%4+'w';
				else if(num>1)ans+=co%3+'a'+3*(num-2);
				co=0;
				num=str[j]-'0';
			}
		}
		cout<<ans<<endl;
	}
}

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

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

using namespace std;

int main(){
    string keitai[10] =
        {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
    string str;
    int n; cin >> n;
    REP(k,n){
        cin >> str;
        int len = str.size();
        int cur=0, cnt=0;
        int tmp;
        REP(i,len){
            if(str[i]=='0'){ //00???????????¨???cnt=0
                if(cnt!=0){
                    if(cnt % keitai[cnt].size()==0){
                        tmp = keitai[cnt].size() - 1;
                    }else{
                        tmp = cnt % keitai[cnt].size() - 1;
                    }
                    cout << keitai[cur][tmp];
                }
                cur=0; cnt=0;
            }else{ //str[i]!='0'
                if(cur==0){//0??\?????\????????????
                    cur = str[i] - '0';
                    cnt++;
                }else{
                    cnt++;
                }
            }
        }
        cout << endl;
    }
    return 0;
}