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.h>
using namespace std;
int main(){
  int n,i,j,len,count,which,flag;
  char in[1025];
  char data[10][6]={
    {' ',' ',' ',' ',' '},
    {'.',',','!','?',' '},
    {'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'}
  };
  cin >> n;
  for(i=0;i<n;i++){
    cin >> in;
    len=strlen(in);
    count=-1;
    which=0;
    for(j=0;j<len;j++){
      flag=0;
      if(in[j]=='1') which=1;
      else if(in[j]=='2') which=2;
      else if(in[j]=='3') which=3;
      else if(in[j]=='4') which=4;
      else if(in[j]=='5') which=5;
      else if(in[j]=='6') which=6;
      else if(in[j]=='7') which=7;
      else if(in[j]=='8') which=8;
      else if(in[j]=='9') which=9;
      else{
        if(which==0) continue;
	if(which==1) count%=5;
	else if(which==2||which==3||which==4||which==5||which==6||which==8) count%=3;
	else if(which==7||which==9) count%=4;
	cout << data[which][count];
	flag=1;
        count=-1;
        which=0;
      }
      if(flag==0) count++;
    }
    cout << endl;
  }
  return 0;
}

C++: #include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<sstream>
#include<iostream>
using namespace std;
struct Data{
    char c;
    int n;
};
int main(void){

    int n;
    cin>>n;
    string str;
    string c[] = {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
    while(n--){
        cin>>str;
        Data a[1200];
        char ch = 'A';
        int t = -1;
        for(int i = 0;i < str.size();i++){
            if(ch == str[i]){
                a[t].n++;
            }
            else{
                ch = str[i];
                t++;
                a[t].c = ch;
                a[t].n = 1;
            }
        }
        t++;
        for(int i = 0;i < t;i++){
            if(a[i].c == '0')continue;
            cout<<c[a[i].c - '0' - 1][(a[i].n - 1)%c[a[i].c - '0' - 1].size()];
        }
        cout<<endl;
    }


    return 0;
}

C++: #include <cstdio>
int main(){
  int N,p,g,a[9]={};
  int i,o;
  char v,prev;
  scanf("%d",&N);
  for(i=1;i<=N+1;i++){
    p=0;
    while(1){
      p++;
      scanf("%c",&v);
      if(v=='\n') break;
      if(v=='1') a[0]++;
      if(v=='2') a[1]++;
      if(v=='3') a[2]++;
      if(v=='4') a[3]++;
      if(v=='5') a[4]++;
      if(v=='6') a[5]++;
      if(v=='7') a[6]++;
      if(v=='8') a[7]++;
      if(v=='9') a[8]++;
      if(v=='0') {
	if(prev=='1') {
	  if(a[0]%5==4) printf("?");
	  if(a[0]%5==1) printf(".");
	  if(a[0]%5==2) printf(",");
	  if(a[0]%5==3) printf("!");
	  if(a[0]%5==0) printf(" ");
	}
	if(prev=='2'){
	  g=a[1]%3;
	  if(g==0) g=3;
	  printf("%c",96+g);
	}
	if(prev=='3'){
	  g=a[2]%3;
	  if(g==0) g=3;
	  printf("%c",99+g);
	}
	if(prev=='4'){
	  g=a[3]%3;
	  if(g==0) g=3;
	  printf("%c",102+g);
	}
	if(prev=='5'){
	  g=a[4]%3;
	  if(g==0) g=3;
	  printf("%c",105+g);
	}
	if(prev=='6'){
	  g=a[5]%4;
	  if(g==0) g=4;
	  printf("%c",108+g);
	}
	if(prev=='7'){
	  g=a[6]%3;
	  if(g==0) g=3;
	  printf("%c",111+g);
	}
	if(prev=='8'){
	  g=a[7]%3;
	  if(g==0) g=3;
	  printf("%c",115+g);
	}
	if(prev=='9'){
	  g=a[8]%4;
	  if(g==0) g=3;
	  printf("%c",118+g);
	}
	for(o=0;o<8;o++){
	  a[o]=0;
	}
      } 
      prev=v;
    }
    if(i>=2)   printf("\n");
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
char in[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 in1[9]={5,3,3,3,3,3,4,3,4};
int main(){
  int n;
  cin>>n;
  rep(j,n){
    string s;
    cin>>s;
    int i=0;
    while(i!=s.size()){
      int co=0;
      while(s[i]!='0'){
	co++;
	i++;
      }
      //cout<<co<<endl;
      if(co)cout<<in[s[i-1]-'0'-1][(co-1)%in1[s[i-1]-'0'-1]];
      i++;
    }
    cout<<endl;
  }
}

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;
			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]=='7'||s[j-1]=='9')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(){
	
	string k[256];
	k['1']=".,!? ";
	k['2']="abc";
	k['3']="def";
	k['4']="ghi";
	k['5']="jkl";
	k['6']="mno";
	k['7']="pqrs";
	k['8']="tuv";
	k['9']="wxyz";
	k['0']="";
	
	int n;cin>>n;
	while(n--){
		string s;cin>>s;
		for(int i=0;i<s.size();i++){
			if(i==0 && s[i]=='0')continue;
			int t=-1;
			while(s[i]!='0'){
				t++;
				i++;
			}
			if(s[i-1]=='0')continue;
			cout<<k[s[i-1]][t%k[s[i-1]].size()];
		}
		cout<<endl;
	}
	
	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
#define P pair<int,string>
const P m[10] = {
  P(0,""), P(5,".,!? "), P(3,"abc"), P(3,"def"), P(3,"ghi"),
  P(3,"jkl"), P(3,"mno"), P(4,"pqrs"), P(3, "tuv"), P(4,"wxyz"),
};
int main()
{
  int n;
  cin >> n;
  while(n--){
    string s;
    cin >> s;
    int p,i,j=0;
    for(i=0;i<s.length();i++){
      if(s[i] == '0' && j != 0){
	cout << (m[p].second)[(j-1)%(m[p].first)];
	j = 0;
      }else if(s[i] != '0'){
	p = s[i] - '0';
	j++;
      }
    }
    cout << endl;
  }
  return 0;
}