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>
#include <string>
using namespace std;

char mes(char c){
    int n = c -'0';
    if(n==2)return 'a';
    else if(n==3)return 'd';
    else if(n==4)return 'g';
    else if(n==5)return 'j';
    else if(n==6)return 'm';
    else if(n==7)return 'p';
    else if(n==8)return 't';
    else return 'w';
}


int main(){
    long long n;
    cin >> n;
    for(int i=0;i<n;i++){
        string str;
        cin >> str;
        int cou = 0;
        for(int j=1;j<str.size();j++){
            if(str[0]!='0')cou=1;
           if(str[j]=='0' && str[j-1]!='0'){
                if(str[j-1]!='0'){
                    if(cou)cou--;
                    if(str[j-1]!='1'){
                        char a = mes(str[j-1]);
                        if(str[j-1]=='7'||str[j-1]=='9')printf("%c",a + (cou)%4);
                        else printf("%c",a+cou%3);
                    }else{
                       cou%=5;
                        if(!cou)cout << ".";
                        else if(cou==1)cout << ",";
                        else if(cou==2)cout << "!";
                        else if(cou==3)cout << "?";
                        else cout << " ";
                    }
                }
                cou = 0;
           }else if(str[j]!='0'){
               cou++;
           }
        }
        cout << endl;
    }
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;

#define MAXLEN 1024
#define MAXCHAR 76

char judge(char c, int x){
  int i;

  if(c == '1'){
    i = x % 5;

    if(i == 0){
      return ' ';
    } else if(i == 1){
      return '.';
    } else if(i == 2){
      return ',';
    } else if(i == 3){
      return '!';
    } else if(i == 4){
      return '?';
    }
    
  } else if(c == '2'){
    i = x % 3;
    printf("i = %d\n", i);
    if(i == 1){
      return 'a';
    } else if(i == 2){
      return 'b';
    } else if(i == 0){
      return 'c';
    }
  } else if(c == '3'){
    i = x % 3;
    if(i == 1){
      return 'd';
    } else if(i == 2){
      return 'e';
    } else if(i == 0){
      return 'f';
    }
  } else if(c == '4'){
    i = x % 3;
    if(i == 1){
      return 'g';
    } else if(i == 2){
      return 'h';
    } else if(i == 0){
      return 'i';
    }
  } else if(c == '5'){
    i = x % 3;
    if(i == 1){
      return 'j';
    } else if(i == 2){
      return 'k';
    } else if(i == 0){
      return 'l';
    }
  } else if(c == '6'){
    i = x % 3;
    if(i == 1){
      return 'm';
    } else if(i == 2){
      return 'n';
    } else if(i == 0){
      return 'o';
    }
  } else if(c == '7'){
    i = x % 4;
    if(i == 1){
      return 'p';
    } else if(i == 2){
      return 'q';
    } else if(i == 3){
      return 'r';
    } else if(i == 4){
      return 's';
    }
  } else if(c == '8'){
    i = x % 3;
    if(i == 1){
      return 't';
    } else if(i == 2){
      return 'u';
    } else if(i = 0){
      return 'v';
    }
  } else if(c == '9'){
    i = x % 4;
    if(i == 1){
      return 'w';
    } else if(i == 2){
      return 'x';
    } else if(i == 3){
      return 'y';
    } else if(i == 0){
      return 'z';
    }
  }

}

void ret_char(char *s, int sp, char *r){
  printf("s = %s\n", s);
  printf("sp = %d\n", sp);

  if(*s != '\0'){
    if(*s == '0'){
      if(sp != 0){
	printf("*(s - 1) = %c, sp = %d\n", *(s - 1), sp);
	*r = judge(*(s - 1), sp);
	printf("%c\n", *r);
	sp = 0;
	s++;
	r++;
	ret_char(s, sp, r); // 再帰
      } else {
	s++;
	ret_char(s, sp, r); // 再帰
      }
    } else {
      s++;
      sp++;
      ret_char(s, sp, r); // 再帰
    }
  }

}

main(){
  int testcase, i, j, count = 0;
  char message[MAXLEN + 1], *rechar = (char *)malloc(sizeof(char) * MAXCHAR);

  cin >> testcase;

  for (i = 0; i < testcase; i++){
    scanf("%s", message);

    message[strlen(message)] = '\0';
    printf("message = %s\n", message);

    ret_char(message, 0, rechar);

    printf("%s\n", rechar);
    strcpy(message, "");
    strcpy(rechar, "");
  }

  return 0;
}

C++: #include<bits/stdc++.h>

using namespace std;

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

int main(){
	
	int n;
	
	cin >> n;
	
	for(int i=0;i<n;i++){
		
		string s;
		
		cin >> s;
		
		int num=0;
		int cnt=0;
		
		for(int j=0;s[j];j++){
			if(s[j]=='0'){
				if(cnt!=0){
					num = s[j-1]-'0';
					cout << c[num][(cnt-1)%c[num].size()];
					cnt=0;
				}
			}else{
				cnt++;
			}
		}
	cout << endl;
	}
				
	return 0;
}

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

int n;

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

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=0; i<n; ++i){
		string s;
		cin >> s;
		string t;
		for(int i=0; i<s.size(); ++i){
			char c = s[i];
			int j = i;
			while(c == s[i]) ++i;
			if(c != '0') t += a[c-'0'][(i-j-1)%(int)(a[c-'0'].size())];
			else --i;
		}
		cout << t << "\n";
	}
}

C++: #include <iostream>
using namespace std;
int main(void){
    char code[][5] = {
        {0,0,0,0,0},
        {'.',',','!','?',' '},
        {97,98,99,0,0},
        {100,101,102,0,0},
        {103,104,105,0,0},
        {106,107,108,0,0},
        {109,110,111,0,0},
        {112,113,114,115,0},
        {116,117,118,0,0},
        {119,120,121,122,0}
    };
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string input;
        cin >> input;
        int num = 0;
        int index = 0;
        for (int j = 0; j < input.length(); ++j) {
            if (input[j] == '0') {
                cout << code[num][index];
                num = 0;
                index = 0;
            } else if (!index && !num) {
                num = input[j] - '0';
            } else {
                while(num) {
                    if (++index == 5) index = 0;
                    if (code[num][index]) break;
                }
            }
        }
        cout << endl;
    }
    return 0;
}

C++: #include <cstdio>
char S[1025];
char ch[10][6]={"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
int size[10]={1,5,3,3,3,3,3,4,3,4};
int main() {
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) {
		scanf("%s",S);
		int idx=0;
		while(S[idx]!='\0') {
			int nxt=idx;
			int len=0;
			while(S[nxt]==S[idx]) {
				nxt++;
				len++;
			}
			if(S[idx]>'0') {
				len--;
				len%=size[S[idx]-'0'];
				putchar(ch[S[idx]-'0'][len]);
			}
			idx=nxt;
		}
		putchar('\n');
	}
}