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<stdio.h>
#include<string.h>
char c[9][6]={".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
char s[1025];
int main(){
	int n,i,j;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf(" %s",s);
		int len=strlen(s);
		int p=-1;
		int cnt=0;
		for(j=0;j<len;j++){
			if(s[j]=='0'){
				if(p==-1)continue;
				if(p==0)cnt%=5;
				else if(p==6||p==8)cnt%=4;
				else cnt%=3;
				printf("%c",c[p][cnt]);
				p=-1;
				cnt=0;
			}else{
				if(p==-1)p=s[j]-'1';
				else cnt++;
			}
		}
		puts("");
	}
	return 0;
}

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

int main() {
    vector<string> v;
    v.push_back(",.!? ");
    v.push_back("abc");
    v.push_back("def");
    v.push_back("ghi");
    v.push_back("jkl");
    v.push_back("mno");
    v.push_back("pqrs");
    v.push_back("tuv");
    v.push_back("wxyz");

    int N;
    cin >> N;
    while (N--) {
        string s;
        cin >> s;
        int x = 0, cnt = 0;
        for (char c : s) {
            if (c == '0') {
                x--;
                cnt--;
                if (x != -1) {
                    cout << v[x][cnt % v[x].size()];
                }
                x = 0;
            } else {
                if (x == 0) {
                    x = c - '0';
                    cnt = 1;
                } else {
                    cnt++;
                }
            }
        }
        cout << endl;
    }
}

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

int main(){

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

  int n;
  cin >> n;
  while( n-- ){
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
      if(s[i] == '0') continue;
      int j = 0;
      while( s[i+j] != '0' ) j++;
      cout << str[ (int)s[i+j-1]-'1' ][ (j-1)%str[ (int)s[i]-'1' ].size()];
      i += j;
    }
    cout << endl;
  }
	return 0 ;
}

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

string order;
vector<int> num;
vector<char> word;
int n;
char button[9][4] = {{'.',',','!','?'},{'a','b','c'},{'d','e','f'},{'g','h','i'},{'i','k','l'},{'m','n','o'},{'p','q','r','s'},{'t','u','v'},{'w','x','y','z'}};

int main()
{
  int but = 0,push = 0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> order;
    for(int j=0;j<order.size();j++){
      num.push_back((int)(order[j]-'0'));
    }
    for(int j=0;j<num.size();j++){
      if(1<=num[j] && num[j]<=9 && but==0){
	but = num[j];
      }else if(1<=num[j] && num[j]<=9 && but!=0){
	push++; //cout << "pushed" << endl;
      }else if(num[j]==0 && but && but!=1 && but!=7 && but!=9){
	word.push_back(button[but-1][push%3]); //cout << button[but-1][push%3] << endl;
	push = 0;
	but = 0;
      }else if(num[j]==0 && but && (but==1 || but==7 || but==9)){
	word.push_back(button[but-1][push%4]); //cout << button[but-1][push%4] << endl;
	push = 0;
	but = 0;
      }else if(num[j]==0 && !but){
	continue;
      }
    }
    for(int k=0;k<word.size();k++){
      cout << word[k];
    }
    cout << endl;
    word.clear();
    num.clear();
  }
  
  return 0;
  
}

C++: #include <cstdio>
#include <cstdlib>
#define STR_MAX 1025

int main () {
  int n;
  int data[ 10 ][ 6 ] = {
    { 0,   0,   0,   0,   0,   0 },
    { 5, '.', ',', '!', '?', ' ' },
    { 3, '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 },
    { 4, 'p', 'q', 'r', 's',   0 },
    { 3, 't', 'u', 'v',   0,   0 },
    { 4, 'w', 'x', 'y', 'z',   0 }
  };
  scanf( "%d", &n );
  for( int i = 0; i < n; i++ ) {
    char instr[ STR_MAX ];
    char outstr[ STR_MAX ];
    int si = 0;
    int counter = 1;
    int tmp = 0;
    scanf( "%s", instr );
    for( int j = 0; instr[ j ] != '\0'; j++ ) {
      if( instr[ j ] == '0' ) {
        if( counter != 1 ){
          outstr[ si++ ] = tmp;
        }
        counter = 1;
        continue;
      }
      if( counter == data[ instr[ j ] - '0' ][ 0 ] + 1 ) {
        counter = 1;
      }
      tmp = data[ instr[ j ] - '0' ][ counter++ ];
    }
    outstr[ si++ ] = '\0';
    puts( outstr );
  }

  return EXIT_SUCCESS;
}