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>
#include<vector>
#include<algorithm>
#include<numeric>

using namespace std;

#define all(i) i.begin(), i.end()
#define rep(i,n) for(int i=0;i<n;i++)

int main()
{
	int num = 0; cin >> num;
	string dat[12] = { "", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };
	rep(i, num)
	{
		string str; cin >> str;
		vector<int> hit(10, 0);
		rep(j, (int)str.size())
		{
			hit[str[j] - '0'] += 1;
			if (j == 0 || str[j - 1] == '0') {}
			else if (str[j] == '0')
			{
				int tmp = str[j - 1] - '0', n = hit[tmp];
				while (1)
				{
					if (n <= (int)dat[tmp].size()) { break; }
					n -= (int)dat[tmp].size();
				}
				printf("%c", dat[tmp][n - 1]);
				rep(i, 10){ hit[i] = 0; }
			}
		}
		printf("\n");
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

string keitai[]{".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
int main(){
	string s;
	while(cin>>s){
		int cnt=0;
		string ans;
		rep(i,s.size()){
			if(s[i]=='0'){
				if(cnt)ans+=keitai[s[i-1]-'1'][(cnt-1)%keitai[s[i-1]-'1'].size()];
				cnt=0;
			}
			else cnt++;
		}
		cout<<ans<<endl;
	}
}

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

using namespace std;

int main()
{
	string bs[10]={
		"",".,!?","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz",
	};
	
	int tc; scanf("%d",&tc);
	while(tc--){
		char s[1025]; scanf("%s",s);
		int n=strlen(s);
		for(int i=0,j;i<n;i=j+1){
			string& b=bs[s[i]-'0'];
			for(j=i;j<n && s[j]>'0';j++);
			if(j==i) continue;
			putchar(b[(j-1-i)%b.size()]);
		}
		puts("");
	}
	
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

//10進数1桁の文字を整数型にする
int toInt(char c){
	return c - '0';
}

int main(){
	const char buttonTable[10][5]={{},//確定ボタン　0
							{'.', ',' ,'!', '?', ' '},//1 (5)
							{'a','b','c'},//2 (3)
							{'d','e','f'},//3 (3)
							{'g','h','i'},//4 (3)
							{'j','k','l'},//5 (3)
							{'m','n','o'},//6 (3)
							{'p','q','r','s'},//7 (4)
							{'t','u','v'},//8 (3)
							{'w','x','y','z'}};//9(4)
	const int bsize[10] = {0,5,3,3,3,3,3,4,3,4};//ボタンの文字の種類
	
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		char command[1025];//char command[1025];
		cin >> command;
		int len = strlen(command);
		char result[76];//作ったメッセージ。サイズは[1,76) \0を忘れずに
		int idx = 0;//resultの入力場所
		int row=0;//ボタンを押した場所。表の行(row)
		int col=0;//同じボタンを押した回数。表の列(column)
		for(int j=0;j<len;j++){
			int button = toInt(command[j]);
			if(button == 0){
				if(row != 0){//文字を入力できる
					result[idx] = buttonTable[row][col];
					idx++;
					row = 0;
					col = 0;
				}
			}else if(button == row){
				col = (col+1)%bsize[button];
				
			}else{//文字を決定した次のコマンド
				row = button;
				//colの値は必ず0
			}
		}
		result[idx] = '\0';
		cout <<result << endl;
		/*for(int i=0;i<idx;i++){//文字列はidx文字ある
			cout << result[i];
		}
		cout << endl;
		*/
	}
	return 0;
}

C++: #define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
#define  rep(i,n) for(int i=0;i<(n);i++)
#define  REP(i,a,n) for(int i=a;i<(n);i++)
#define  rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define  VI	vector<int>
#define	 VS vector<string>
#define  all(a) (a).begin(),(a).end()
#define  debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int INF=1000000;
char fi[101][101];
int d[21][21];
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int N,M;
int sx,sy;
int gx,gy;
int w,h;
int ans;

int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int MAX_V=100;
const int MAX_N=100;
char o[3]={'+','-','*'};
#define md 1000003

int dp[353][353]={0};
int bow[353][353]={0};


int main(){
	
	string s;
	int n;
	cin>>n;
	while(n>0){
		cin>>s;
		vector<string> p(10);
		p[1]=".,!? ";
		p[2]="abc";
		p[3]="def";
		p[4]="ghi";
		p[5]="jkl";
		p[6]="mno";
		p[7]="pqrs";
		p[8]="tuv";
		p[9]="wxyz";
		bool f=false;
		char c='0';
		int count=0;
		string a="";
		rep(i,s.size()){
			if(s[i]=='0'){
				if(f){
				if(c=='1'){
					count=(count-1)%5;
				}
				else if(c=='7'||c=='9'){
					count=(count-1)%4;
				}
				else{
					count=(count-1)%3;
				}
				a+=p[c-'0'][count];
				f=false;
				count=0;
				c='0';
				}
			}
			else{
				f=true;
				if(c!=s[i]){
					c=s[i];
					count=1;
				}
				else
					count++;
				
			}
			
		}
		cout<<a<<endl;
		n--;
	}
	
}

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

char b1[5]={'.' , ',' , '!' , '?' , ' '};
char b2[3]={'a' , 'b' , 'c'};
char b3[3]={'d' , 'e' , 'f'};
char b4[3]={'g' , 'h' , 'i'};
char b5[3]={'j' , 'k' , 'l'};
char b6[3]={'m' , 'n' , 'o'};
char b7[4]={'p' , 'q' , 'r' , 's'};
char b8[3]={'t' , 'u' , 'v'};
char b9[4]={'w' , 'x' , 'y' , 'z'};

int main()
{
	int n;
	cin>>n;
	while(n--)
	{
		string in,out;
		cin>>in;
		int cnt=0;
		for(int i=0;i<in.size();i++)
		{
			if(in[i]==0&&cnt==0) continue;
			else if(in[i]!='0') cnt++;
			else
			{
				switch(in[i-1]){
					case '1':
						out+=b1[(cnt-1)%5];
						break;
					case '2':
						out+=b2[(cnt-1)%3];
						break;
					case '3':
						out+=b3[(cnt-1)%3];
						break;
					case '4':
						out+=b4[(cnt-1)%3];
						break;
					case '5':
						out+=b5[(cnt-1)%3];
						break;
					case '6':
						out+=b6[(cnt-1)%3];
						break;
					case '7':
						out+=b7[(cnt-1)%4];
						break;
					case '8':
						out+=b8[(cnt-1)%3];
						break;
					case '9':
						out+=b9[(cnt-1)%4];
						break;
				}
				cnt=0;
			}
		}
		cout<<out<<endl;
	}
	return 0;
}

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

char data[10][5] = {'E','E','E','E','E',
		    '.', ',', '!' ,'?' ,' ',
		    'a', 'b', 'c', 'E', 'E',
		    'd','e','f','E','E',
		    'g','h','i','E','E',
		    'j','k','l','E','E',
		    'm','n','o','E','E',
		    'p','q','r','s','E',
		    't','u','v','E','E',
		    'w','x','y','z','E'};

char in;
int col=-1, row=0;
int num;
int state = 0;

int main(){
  int N;
  cin >> N;
  while(N--){
    cin.ignore();
    while(scanf("%c",&in) != EOF){
     
      if(in == '0'){
	if(col == -1) col++;
	if(row >= 2 && row <= 6 || row == 8) num = 3;
	else if(row == 1) num = 5;
	else num = 4;
	
	if(data[row][col%num] != 'E'){
	  cout << data[row][col%num];
	  state = 1;
      }
	col = -1;
	row = 0;
      }else{
	col++;
	row=in-48;
      }
      if(in == '\n'){
	if(state == 1) cout << endl;
	state = 0;
      col = -1;
      row = 0;
      }
      
    }
    if(data[row][col%num] != 'E'){
      cout << data[row][col%num];
      //state = 1;
    }
    if(state == 1) cout << endl;
  }
    return 0;
}