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;

int    nextInt()    { int d;      cin >> d;   return d;   }
string nextString() { string str; cin >> str; return str; }

string solve(string input) {
  string ret;

  char keys[][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 key_size[] = {
    -1, 5, 3, 3, 3, 3, 3, 4, 3, 4
  };
  
  char next = '\0';
  int idx = 0;
  for (int i = 0; i < input.size(); i++) {
    char c = input[i];
    if (c == '0') {
      if (next > 0 && next < 128) {
        ret += next;
      }
      next = '\0';
      idx = 0;
    } else {
      next = keys[c - '0'][idx];
      idx = (idx + 1) % key_size[c - '0'];
    }
  }
  
  return ret;
}

int main() {
  int n = nextInt();
  for (int i = 0; i < n; i++) {
    string input = nextString();
    cout << solve(input) << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it = (c).begin(); it != (c).end(); it++)
#define X first
#define Y second

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const string L[10] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
int main(void){
    int n; cin >> n;
    for(string in; n-- && cin >> in; cout << endl){
        int cur = 0, cnt = 0;
        rep(i, in.size()){
            if(in.at(i) - '0' == cur) cnt++;
            else{
                if(in.at(i) == '0'){
                    cout << L[cur].at((cnt + L[cur].size()) % L[cur].size());
                }
                cur = in.at(i) - '0';
                cnt = 0;
            }
        }
    }

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
vector<vector<char> > button(10);


int main(void){
  char c = 'a';
  button[1].push_back('.');
  button[1].push_back(',');
  button[1].push_back('!');
  button[1].push_back('?');
  button[1].push_back(' ');
  for(int i=2; i <= 9; i++){
    if(i == 7 || i == 9){
      for(int j=0; j < 4; j++){
	button[i].push_back(c);
	c++;
      }
    }else{
      for(int j=0; j < 3; j++){
	button[i].push_back(c);
	c++;
      }
    }
  }


  int n;
  string s;
  cin >> n;
  while(n--){
    cin >> s;
    int cnt=0;
    string mes;
    for(int i=0; i < s.length(); i++){
      if(s[i] == '0'){
	if(i == 0)      continue;
	if(s[i-1] == '0') continue;
	mes.append(1, button[s[i-1]-'0'][(cnt-1)%button[s[i-1]-'0'].size()]);
	cnt = 0;
      }else{
	cnt++;
      }
    }
    cout << mes << endl;
  }
  return 0;
}

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

using namespace std;

const char keibutton[10][5]={{'\0','\0','\0','\0','\0'},
							 {'.',',','!','?',' '}, //1
						     {'a','b','c'},     //2
						     {'d','e','f'},     //3
						     {'g','h','i'},     //4
						     {'j','k','l'},     //5
						     {'m','n','o'},     //6
						     {'p','q','r','s'}, //7
						     {'t','u','v'},     //8
						     {'w','x','y','z'}};//9


int main(){
	int n,cnt,outcnt,inpcnt;
	char str[1025],outputStr[1025];
	
	cin>>n;
	
	for(int z=0;z<n;z++){
		
		fill(str,str+1025,'\0');
		fill(outputStr,outputStr+1025,'\0');
		cnt=-1;
		inpcnt=0;
		outcnt=0;
		
		cin>>str;
		
		while(true){
			if(str[inpcnt]=='\0'){
				break;
			}
			inpcnt++;
		}
		
		for(int i=0;i<inpcnt;i++){
			if(str[i]=='0'){
				if(i>0 && str[i-1]!='0'){
					outputStr[outcnt]=keibutton[str[i-1]-'0'][cnt];
					outcnt++;
				}
				cnt=-1;
			}
			else if(str[i]=='1'){
				if(cnt>=5){
					cnt=0;
				}
				else{
					cnt++;
				}
			}
			else if(str[i]=='7' || str[i]=='9'){
				if(cnt>=3){
					cnt=0;
				}
				else{
					cnt++;
				}
			}
			else{
				if(cnt>=2){
					cnt=0;
				}
				else{
					cnt++;
				}
			}
		}
		cout<<outputStr<<endl;
	}
}

C++: #include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>

#define REP(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
#define ALLOF(c) c.begin(), c.end()
#define RANGEOF(c,i,n) c.begin() + (i), c.begin() + (i) + (n)
#define EPS 1e-9
#define INF 1000000000
using namespace std;

template <class T> T read() { T t; cin >> t; return t; }
template <class T> vector<T> read(int n) { vector<T> v; REP(i,n) { v.push_back(read<T>()); } return v; }
template <class T> vector<vector<T>> read(int n, int m)
{
	vector<vector<T>> v;
	REP(i,n) { v.push_back(read<T>(m)); }
	return v;
}

template <class T> void write(const T &t) { cout << t << endl; }
template <class T> void write(const T &t, const T &t2) { cout << t << ' ' << t2 << endl; }
template <class T> void write(const vector<T> &v)
{
	ostringstream ss; 
	for (auto x : v) ss << x << ' ';
	auto s = ss.str();
	cout << s.substr(0, s.length() - 1) << endl;
}

struct _Reader { template <class T> _Reader operator ,(T &rhs) { cin >> rhs; return *this; } };
#define READ(t,...) t __VA_ARGS__; _Reader(), __VA_ARGS__

void solve();
int main() { solve(); return 0; }

/// template end ///

void solve()
{
	READ(int, datasets);
	const string tbl[] = { ".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz" };
	REP(dataset, datasets)
	{
		READ(string, input);
		string ret;
		for (auto it = input.begin(); it != input.end(); it++)
		{
			int c = *it - '0';
			if (c != 0)
			{
				const string &t = tbl[c - 1];
				auto f = find(it + 1, input.end(), '0');
				ret.push_back(t[(f - it - 1) % t.length()]);
				it = f;
			}
		}
		write(ret);
	}
}

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

using namespace std;

int main()
{
  vector<string> keitai(9);
  keitai[0] = ".,!? ";  keitai[1] = "abc";  keitai[2] = "def";  keitai[3] = "ghi";
  keitai[4] = "jkl";  keitai[5] = "mno";  keitai[6] = "pqrs"; keitai[7] = "tuv";  keitai[8] = "wxyz";

  int N;
  cin>>N;

  for(int i = 0;i < N;++i){
    string input,output;
    cin>>input;

    int word,t = 0;
    for(int j = 0;j < input.size();++j){
      if(input[j] == '0' && word != 0){
        int num = t % keitai[word - 1].size();
        if(num == 0){
          num = keitai[word - 1].size();
        }
        output = output + keitai[word - 1][num - 1];
        t = 0;
        word = 0;
      }
      else{
        word = input[j] - '0';
        if(word != 0){
          ++t;
        }
      }
    }
    cout<<output<<endl;
  }

  return 0;
}