Go: // Keitai Message
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2006&lang=jp
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var table = []string{
	"",
	".,!? ",
	"abc",
	"def",
	"ghi",
	"jkl",
	"mno",
	"pqrs",
	"tuv",
	"wxyz",
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	n := nextInt(sc)

	for i := 0; i < n; i++ {
		message := nextString(sc)
		currentButton, count := 0, 0
		for _, word := range message {
			// 確定の処理を書く
			if word == '0' {
				if currentButton == 0 {
					count = 0
					continue
				}
				mod := len(table[currentButton])
				tmp := table[currentButton][(count-1)%mod]
				currentButton, count = 0, 0
				fmt.Printf("%c", tmp)
			} else {
				count++
				currentButton = int(word) - 48 // '0'はASCIIで48
			}
		}
		fmt.Println()
	}
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

C++: #include <iostream>
using namespace std;
bool flag;
int i,j,k,n;
string s;
string out;
char button[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 main(){
	cin >> n;
	for(int p=0;p<n;p++){
		cin >> s;
		flag=false;
		i=-1;
		j=k=0;
		while(k!=s.size()){
			switch(s[k]){
				case'1':
				if(i==0){
					j++;
				}else{
					j=0;
					i=0;
				}
				if(j==5)j=0;
				break;
				case'2':
				if(i==1){
					j++;
				}else{
					j=0;
					i=1;
				}
				if(j==3)j=0;
				break;
				case'3':
				if(i==2){
					j++;
				}else{
					j=0;
					i=2;
				}
				if(j==3)j=0;
				break;
				case'4':
				if(i==3){
					j++;
				}else{
					j=0;
					i=3;
				}
				if(j==3)j=0;
				break;
				case'5':
				if(i==4){
					j++;
				}else{
					j=0;
					i=4;
				}
				if(j==3)j=0;
				break;
				case'6':
				if(i==5){
					j++;
				}else{
					j=0;
					i=5;
				}
				if(j==3)j=0;
				break;
				case'7':
				if(i==6){
					j++;
				}else{
					j=0;
					i=6;
				}
				if(j==4)j=0;
				break;
				case'8':
				if(i==7){
					j++;
				}else{
					j=0;
					i=7;
				}
				if(j==3)j=0;
				break;
				case'9':
				if(i==8){
					j++;
				}else{
					j=0;
					i=8;
				}
				if(j==4)j=0;
				break;
				case'0':
				if(i!=-1)cout <<button[i][j];
				flag=true;
				i=-1;
				break;
			}
			k++;
		}
		if(flag)cout <<endl;

	}

	return  0;
}

C++: // AOJ 2006
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main() {
  string input;
  string trm = "cfilov";
  while (cin >> input) {
    char c = '\0', current = '\0';
    for (char btn : input) {
      if (c == '\0') {
        if (btn == '1') {
          c = '.';
        } else if (btn == '2') {
          c = 'a';
        } else if (btn == '3') {
          c = 'd';
        } else if (btn == '4') {
          c = 'g';
        } else if (btn == '5') {
          c = 'j';
        } else if (btn == '6') {
          c = 'm';
        } else if (btn == '7') {
          c = 'p';
        } else if (btn == '8') {
          c = 't';
        } else if (btn == '9') {
          c = 'w';
        }
        current = btn;
      } else if (btn == '0') {
        cout << c;
        c = current = '\0';
      } else {
        if (btn != current) {
      //    cout << "guwaa!" << endl;
          goto END;
        }
        if (c == 's' or c == 'z') {
          c -= 3;
        } else if (find(trm.begin(), trm.end(), c) != trm.end()) {
          c -= 2;
        } else if (c == '.') {
          c = ',';
        } else if (c == ',') {
          c = '!';
        } else if (c == '!') {
          c = '?';
        } else if (c == '?') {
          c = ' ';
        } else if (c == ' ') {
          c = '.';
        } else {
          c++;
        }
      }
    }
    cout << endl;
END:
    ;
  }
}

C++: #include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>


int main()
{
	int i,j,k;
	int n,m;
	int a[10]={0}; //押された回数
	int b[10]={0,4,3,3,3,3,3,4,3,4}; //割り算	 
	int c; //押されたボタン
	char d[5][10]={
	{'0','?','c','f','i','l','o','s','v','z'},
	{'0','.','a','d','g','j','m','p','t','w'},
	{'0',',','b','e','h','k','n','q','u','x'},
	{'0','!','0','0','0','0','0','r','0','y'}
	{'0',' ','0','0','0','0','0','0','0','0'}};
	char e[77];
	
	scanf("%d",&n);

	for(i=0;i<n;i++)
	{
		scanf("%s",e);
		for(j=0;j<strlen(e);j++)
		{
			if(e[j]=='0'){
				printf("%c",d[a[c]%b[c]][c]);
				a[c]=0;
			}else
			{
				if(e[j]=='1')c=1;
				else if(e[j]=='2')c=2;
				else if(e[j]=='3')c=3;
				else if(e[j]=='4')c=4;
				else if(e[j]=='5')c=5;
				else if(e[j]=='6')c=6;
				else if(e[j]=='7')c=7;
				else if(e[j]=='8')c=8;
				else if(e[j]=='9')c=9;
				a[c]++;
			}
		}
		printf("\n");
	}

	return 0;
}

C++: /*AOJproblem #2006*/

#include<stdio.h>
#define NUM 2014 //入力文字数のmax

void print_message(const char* input)
{
    static const char button1[] = {'.', ',', '!', '?', ' '};
    static const char button2[] = {'a', 'b', 'c'};
    static const char button3[] = {'d', 'e', 'f'};
    static const char button4[] = {'g', 'h', 'i'};
    static const char button5[] = {'j', 'k', 'l'};
    static const char button6[] = {'m', 'n', 'o'};
    static const char button7[] = {'p', 'q', 'r', 's'};
    static const char button8[] = {'t', 'u', 'v'};
    static const char button9[] = {'w', 'x', 'y', 'z'};
    static const char* buttons[] = {button1, button2, button3, button4, button5, button6, button7, button8, button9};//各ボタンの先頭のポインタの配列
    static const int syuuki[] = {5, 3, 3, 3, 3, 3, 4, 3, 4};//それぞれのボタンを何回押すと一周するか


    int i = 0;
    while (1) {
        while (input[i] == '0') {
            ++i;
        }
        //i++;
        if (input[i] == '\0') break;
        
        char c = input[i];
        int count = 0;//何回連続して同じ文字を入力するか

        while (input[i + ++count] != '0'){//'0'が入力されるまでカウント
            //count++;
        }
        i += count;
        printf("%c", buttons[c - '1'][(count - 1) % (syuuki[c - '1'])]);
    }

    printf("\n");
}

int main(void)
{
    int n = 0;
    scanf("%d", &n);

    while (n--) {
        char input_str[NUM + 1] = {0};
        scanf("%s", input_str);
        print_message(input_str);
    }

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){int m,i;char s[1030];char t[20][6]={" ",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};cin>>m;while(cin>>s){for(i=m=0;s[i]!='\0';i++)if(s[i]=='0'){if(m)cout<<t[s[i-1]-'0'][(m-1)%strlen(t[s[i-1]-'0'])];m=0;}else
m++;cout<<endl;}return 0;}

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

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

string solve(string in){
  string res="";
  int c=0;
  int n_in=0;
  for(int i=0;i<in.size();i++){
    int t_in=in[i]-'0';
    if(t_in==0){
      if(n_in!=0){
        res+=push[n_in][(c%push[n_in].size())];
      }
      n_in=0;
      c=0;
    }else{
      if(t_in==n_in){
        c++;
      }else{
        if(n_in!=0){
          res+=push[n_in][(c%push[n_in].size())];
	}
        c=0;
	n_in=t_in;
      }
    }
  }
  return res;
}



int main(){
  string in;
  while(cin>>in){
    string ans=solve(in);
    if(ans.size()!=0){
      cout<<ans<<endl;
    }
  }
}