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;

int main(){
	int tn=0;
	string input;
	char charl[32]=".,!? abcdefghijklmnopqrstuvwxyz";
	int charn[10]={0,5,8,11,14,17,20,24,27,31};
	cin >> tn;
	for (int i=0;i<tn;i++){
		int cu=0;
		string outs;
		int temp=0;
		cin >> input;
		for (string::iterator it=input.begin();it!=input.end();it++){
			int inp=(int)(*it -'0');
			if(inp==0){
				if(cu!=0){
					cu+=temp;
					temp=0;
					outs+=charl[cu-1];
					cu=0;
				}
			}else{
				if(cu==0){
					cu=charn[inp-1]+1;
				}else{
					temp++;
					temp%=(charn[inp]-charn[inp-1]);
				}
			}
		}
		cout << outs << endl;
	}
}

C++: #include <stdio.h>
#include <string.h>

const char word[9][6] = {{".,!? "},{"abc"},{"def"},{"ghi"},{"jkl"},{"mno"},{"pqrs"},{"tuv"},{"wxyz"}};
const char len[9] = {5,3,3,3,3,3,4,3,4};
int main(void){
	char str[76], tmp;
	int n, i, j, count;
	scanf("%d%*c",&n);
	for(i = 0;i < n;i++){
		gets(str);
		str[strlen(str)] = '\0';
		j = 0;
		while(str[j] != '\0'){
			tmp = str[j];
			if(tmp != '0'){
				count = 1;
				while(str[++j] == tmp)
					count++;
				putchar(word[tmp - '1'][(count - 1) % len[tmp - '1']]);
			}
			else
				j++;
		}
		printf("\n");
	}
	return 0;
}

C++: #include <cstdio>
#include <cstring>

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

int main() {
  char s[1025], ans[77];
  int n;
  scanf("%d", &n);
  for (int i=0;i<n;i++) {
    scanf("%s", s);
    int ai = 0, tt = -1, ti = -1;
    for (int j=0;s[j]!='\0';j++) {
      if (s[j] == '0') {
        if (tt >= 0) {
          ans[ai++] = tbl[tt][ti];
          tt = ti = -1;
        }
      } else {
        tt = s[j]-'1';
        ti = (++ti)%strlen(tbl[tt]);
      }
    }
    ans[ai] = '\0';
    printf("%s\n", ans);
  }
  return 0;
}

C++: #include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;

void one(int num)
{
	switch (num % 5)
	{
	case 1: cout << ".";
		break;
	case 2: cout << ",";
		break;
	case 3: cout << "!";
		break;
	case 4: cout << "?";
		break;
	case 0:cout << " ";
		break;
	}
}
void two(int num)
{
	switch (num % 3)
	{
	case 1: cout << "a";
		break;
	case 2: cout << "b";
		break;
	case 0: cout << "c";
		break;
	}
}
void three(int num)
{
	switch (num % 3)
	{
	case 1: cout << "d";
		break;
	case 2: cout << "e";
		break;
	case 0: cout << "f";
		break;
	}
}
void four(int num)
{
	switch (num % 3)
	{
	case 1: cout << "g";
		break;
	case 2: cout << "h";
		break;
	case 0: cout << "i";
		break;
	}
}
void five(int num)
{
	switch (num % 3)
	{
	case 1: cout << "j";
		break;
	case 2: cout << "k";
		break;
	case 0: cout << "l";
		break;
	}
}
void six(int num)
{
	switch (num % 3)
	{
	case 1: cout << "m";
		break;
	case 2: cout << "n";
		break;
	case 0: cout << "o";
		break;
	}
}
void seven(int num)
{
	switch (num % 4)
	{
	case 1: cout << "p";
		break;
	case 2: cout << "q";
		break;
	case 3: cout << "r";
		break;
	case 0: cout << "s";
		break;
	}
}
void eight(int num)
{
	switch (num % 3)
	{
	case 1: cout << "t";
		break;
	case 2: cout << "u";
		break;
	case 0: cout << "v";
		break;
	}
}
void nine(int num)
{
	switch (num % 4)
	{
	case 1: cout << "w";
		break;
	case 2: cout << "x";
		break;
	case 3:cout << "y";
		break;
	case 0: cout << "z";
	}
}
void clear(int a, int aa, int aaa, int b, int bb, int bbb, int c, int cc, int ccc)
{
	a = 0; aa = 0; aaa = 0;
	b = 0; bb = 0; bbb = 0;
	c = 0; cc = 0; ccc = 0;
}
int main(void)
{
	long long int n,a,aa,aaa,b,bb,bbb,c,cc,ccc;
	string str;
	cin >> n;
	a = 0; aa = 0; aaa = 0;
	b = 0; bb = 0; bbb = 0;
	c = 0; cc = 0; ccc = 0;
	long long int i,t;
	for (i = 0; i < n; i++)
	{
		cin >> str;
		clear(a, aa, aaa, b, bb, bbb, c, cc, ccc);
		int length = str.length();
		for (t = 0; t < length; t++)
		{
			switch (str[t])
			{
			case '0': 
				if (a > 0)
				{
					one(a);
				}
				else if (aa > 0)
				{
					two(aa);
				}
				else if (aaa > 0)
				{
					three(aaa);
				}
				else if (b > 0)
				{
					four(b);
				}
				else if (bb > 0)
				{
					five(bb);
				}
				else if (bbb > 0)
				{
					six(bbb);
				}
				else if (c > 0)
				{
					seven(c);
				}
				else if (cc > 0)
				{
					eight(cc);
				}
				else if (ccc > 0)
				{
					nine(ccc);
				}
				a = 0; aa = 0; aaa = 0;
				b = 0; bb = 0; bbb = 0;
				c = 0; cc = 0; ccc = 0;
				break;

			case '1': a++;
				break;
			case '2': aa++;
				break;
			case '3': aaa++;
				break;
			case '4': b++;
				break;
			case '5': bb++;
				break;
			case '6': bbb++;
				break;
			case '7': c++;
				break;
			case '8': cc++;
				break;
			case '9': ccc++;
				break;
			}
	
		}
		cout << endl;
	}

	return 0;

}

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

using namespace std;

string keyd[] = {"",".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
bool keysize[] = {false, false, false, false, false, false, false, true, false, true};
int main(){
	int n; cin >> n;
	for(int i = 0; i < n; i++){
		string input; cin >> input;
		int pos = -1, key = 0;
		string::iterator itr = input.begin();
		while(itr != input.end()){
			if( *itr == '0'){
				if(key == 0){
					itr++;
					continue;
				}
				if(keysize[key]) pos = pos % 4;
				else if(key == 1) pos = pos % 5;
				else pos = pos % 3;
				cout << keyd[key][pos];
				pos = -1;
			}
			else{
				if(pos == -1)key = *itr - '0';
				pos++;
			}
			itr++;
		}
		cout << endl;
	}

	return 0;
}