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 <bits/stdc++.h>
#define rep( i, begin, end) for( int i = begin; i < end; i++ )
using namespace std;
 
string button[10] = { "", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };
 
int main() {
    int n;
    cin >> n;
    rep( i, 0, n ) {
        string input, message = "";
        cin >> input;
        int key = 0, position = 0;
        rep( i, 0, input.size() ) {
            if ( input[i] == '0' ) {
                if ( key == 0 )
                    continue;
                position %= button[key].size();
                message += button[key][position];
                key = 0;
                position = 0;
            }
            else if ( key == 0 ) {
                key = input[i] - '0';
                position = 0;
            }
            else if ( key == input[i] - '0') {
                position++;
            }
        }
        cout << message << endl;
    }
    
    return 0;
}

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

int main() {

  int left, right;
  char key[10][10] = {
    {},
    {'.', ',', '!', '?', ' '},
    {'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 size[10] = {0, 5, 3, 3, 3, 3, 3, 4, 3, 4};
  int N;
  char str[1024];
  
  std::cin >> N;
  
  for(int t = 0; t < N; ++t) {  
    scanf("%s", str);

    std::vector<char> buffer;
    int n = strlen(str);
  
    left = right = 0;
    for(int i = 0; right <= n; ++right) {
      if( str[left] != str[right] ) {
        if( str[left] != '0' ) {
          buffer.push_back(key[str[left] - '0'][(right-left-1)%size[str[left]-'0']]);
        }
        left = right;
      }
    }
    buffer.push_back('\0');

    std::cout << &buffer[0] << std::endl;
    buffer.clear();
  }
  
  return 0;
}

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

int boo(int x, int y){
	if(x%y) return x%y -1;
	else return y - 1;
}

char foo(string str,int mk, int i){
	char ch, mozi[16] = "00adgjmptw", mozi1[8] = " .,!?";
	if(str[mk] - '0' == 1) ch = mozi1[(i - mk)%5];
	else if(((str[mk] - '0') == 7) || ((str[mk] - '0') == 9)) ch = mozi[str[mk] - '0'] + boo(i - mk, 4);
	else ch = mozi[str[mk] - '0'] + boo(i - mk, 3);
	return ch;
}

int main(){
	int N, mk, count, temp;
	int i, j, k;
	string str;
	char ch[2000];
	
	cin>>N;
	
	for(i = 0; i < N; i++){
		mk=0; count=0;
		cin>>str;
		for(j = 0; j < (int)str.size(); j++){
			if(str[j] == '0'){
				if(mk != j)ch[count++] = foo(str, mk, j);
				mk =  j + 1;
			}
		}
		
		for(j = 0; j < count; j++) cout<<ch[j];
		if(count)cout<<endl;
	}
	
	return 0;
}

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

int main(){

  string s;
  int n;
  char in;
  int num=0 , count=0;

  cin >> n;
  getchar();

  for(int i=0; i<n; i++){

    s = "";
    
    while(scanf("%c",&in)){
      if(in == '\n' ){ break; }

      else if(in == '0'){
 
	  if(num==2)
	    s += 'a'+(count-1)%3;
	  else if(num==3)
	    s += 'd'+(count-1)%3;
	  else if(num==4)
	    s += 'g'+(count-1)%3;
	  else if(num==5)
	    s += 'j'+(count-1)%3;
	  else if(num==6)
	    s += 'm'+(count-1)%3;
	  else if(num==7)
	    s += 'p'+(count-1)%4;
	  else if(num==8)
	    s += 't'+(count-1)%3;
	  else if(num==9)
	    s += 'w'+(count-1)%4;
	  else if(num==1){
	    switch((count-1)%5){
	    case 0: s+='.'; break;
	    case 1: s+=','; break;
	    case 2: s+='!'; break;
	    case 3: s+='?'; break;
	    default: s+=' ';
	    }
	  }

	  num = 0;
	  count = 0;

      }
      //kakutei

      else{
	if(in-'0' == num)
	  count ++;
	else{
	  num = in-'0';
	  count = 1;
	}
      }
    }
    //while

    cout << s << endl;

  }
	    
  return 0;
}

C++: #include<stdio.h>
int main()
{
  char c;
  int n;
  int out;
  int end;
  int i;
  scanf("%d",&n);
  for(i=0;i<n+1;i++)
    {
      end=0;
      while(1)
	{
	  out=0;
	  while(1)
	    {
	      scanf("%c",&c);
	      if(out==0)
		{
		  switch(c)
		    {
		    case '1':
		      out=1;
		      break;
		    case '2':
		      out=6;
		      break;
		    case '3':
		      out=9;
		      break;
		    case '4':
		      out=12;
		      break;
		    case '5':
		      out=15;
		      break;
		    case '6':
		      out=18;
		      break;
		    case '7':
		      out=21;
		      break;
		    case '8':
		      out=25;
		      break;
		    case '9':
		      out=28;
		      break;
		    }
		}
	      else
		{
		  switch(c)
		    {
		    case '1':
		      if(out==5) out=1;
		      else out++;
		      break;
		    case '2':
		      if(out==8) out=6;
		      else out++;
		      break;
		    case '3':
		      if(out==11) out=9;
		      else out++;
		      break;
		    case '4':
		      if(out==14) out=12;
		      else out++;
		      break;
		    case '5':
		      if(out==17) out=15;
		      else out++;
		      break;
		    case '6':
		      if(out==20) out=18;
		      else out++;
		      break;
		    case '7':
		      if(out==24) out=21;
		      else out++;
		      break;
		    case '8':
		      if(out==27) out=25;
		      else out++;
		      break;
		    case '9':
		      if(out==31) out=28;
		      else out++;
		      break;
		    }
		}
	      if(c=='\n')
		{
		  end=1;
		  break;
		}
	      if(c=='0') break;
	    }
	  switch(out)
	    {
	    case 1:
	      printf(".");
	      break;
	    case 2:
	      printf(",");
	      break;
	    case 3:
	      printf("!");
	      break;
	    case 4:
	      printf("?");
	      break;
	    case 5:
	      printf(" ");
	      break;
	    case 6:
	      printf("a");
	      break;
	    case 7:
	      printf("b");
	      break;
	    case 8:
	      printf("c");
	      break;
	    case 9:
	      printf("d");
	      break;
	    case 10:
	      printf("e");
	      break;
	    case 11:
	      printf("f");
	      break;
	    case 12:
	      printf("g");
	      break;
	    case 13:
	      printf("h");
	      break;
	    case 14:
	      printf("i");
	      break;
	    case 15:
	      printf("j");
	      break;
	    case 16:
	      printf("k");
	      break;
	    case 17:
	      printf("l");
	      break;
	    case 18:
	      printf("m");
	      break;
	    case 19:
	      printf("n");
	      break;
	    case 20:
	      printf("o");
	      break;
	    case 21:
	      printf("p");
	      break;
	    case 22:
	      printf("q");
	      break;
	    case 23:
	      printf("r");
	      break;
	    case 24:
	      printf("s");
	      break;
	    case 25:
	      printf("t");
	      break;
	    case 26:
	      printf("u");
	      break;
	    case 27:
	      printf("v");
	      break;
	    case 28:
	      printf("w");
	      break;
	    case 29:
	      printf("x");
	      break;
	    case 30:
	      printf("y");
	      break;
	    case 31:
	      printf("z");
	      break;
	    }
	  if(end) break;
	}
      if(i!=0) printf("\n");	 
    }
  return 0;
}