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

string order;
vector<int> num;
vector<char> word;
int n;
char button[9][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 main()
{
        int but = 0,push = 0;
        cin >> n;
        for(int i=0;i<n;i++){
                cin >> order;
                for(int j=0;j<order.size();j++){
                        num.push_back((int)(order[j]-'0'));
                }
                for(int j=0;j<num.size();j++){
                        if(1<=num[j] && num[j]<=9 && but==0){
                                but = num[j];
                        }else if(1<=num[j] && num[j]<=9 && but!=0){
                                push++; //cout << "pushed" << endl;
                        }else if(num[j]==0 && but && but!=1 && but!=7 && but!=9){
                                word.push_back(button[but-1][push%3]); //cout << button[but-1][push%3] << endl;
                                push = 0;
                                but = 0;
                        }else if(num[j]==0 && but && (but==7 || but==9)){
                                word.push_back(button[but-1][push%4]); //cout << button[but-1][push%4] << endl;
                                push = 0;
                                but = 0;
                        }else if(num[j]==0 && but && but==1){
                                word.push_back(button[but-1][push%5]);
                                push = 0;
                                but = 0;
                        }else if(num[j]==0 && !but){
                                continue;
                        }
                }
                for(int k=0;k<word.size();k++){
                        cout << word[k];
                }
                cout << endl;
                word.clear();
                num.clear();
        }

        return 0;

}

C++: #include <iostream>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>


using namespace std;

int main() {
	vector< string > keitai;

	keitai.push_back(".,!? "); keitai.push_back("abc"); keitai.push_back("def"); keitai.push_back("ghi"); keitai.push_back("jkl");
	keitai.push_back("mno"); keitai.push_back("pqrs"); keitai.push_back("tuv"); keitai.push_back("wxyz");

	vector< int > count(keitai.size(), 0);

	int n;
	cin >> n;

	vector< string > s;
	for(int i = 0; i < n; i++) {
		string tmp;
		cin >> tmp;
		s.push_back(tmp);
	}

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

		for(int j = 0; j < s[i].size(); j++) {
			if(s[i][j] == '0') {
				fill(count.begin(), count.end(), 0);
				continue;
			}

			if(j == 0) {
				fill(count.begin(), count.end(), 0);
				ans.push_back(' ');
			} else if(s[i][j - 1] == '0' && s[i][j] != '0') {
				fill(count.begin(), count.end(), 0);
				ans.push_back(' ');
			}

			ans[ans.size() - 1] = keitai[s[i][j] - '0' - 1][count[s[i][j] - '0' - 1] % keitai[s[i][j] - '0' - 1].size()];
			count[s[i][j] - '0' - 1]++;
		}

		cout << ans << endl;
	}
}

C++: #include<iostream>

using namespace std;

int main()
{
  int ab;
  cin>>ab;

  for(;ab--;)
    {
      string s;
      cin>>s;
      char x;
      int count=0;
      bool out=true;
      for(int i=0;i<s.size();i++)
	{
	  if(s[i]!='0')
	    count++;
	    
	  if(s[i]=='1')
	    {
	      string t=".,!? ";
	      if(count%t.size()==0)
		x=t[t.size()-1];
	      else
	      x=t[count%t.size()-1];
	    }
	  if(s[i]=='2')
	    {
	      string t="abc";
	      if(count%t.size()==0)
		x=t[t.size()-1];
	      else
	      x=t[count%t.size()-1];
	    }
	  if(s[i]=='3')
	    {
	      string t="def";
	      if(count%t.size()==0)
		x=t[t.size()-1];
	      else

	      x=t[count%t.size()-1];
	    }
	  if(s[i]=='4')
	    {
	      string t="ghi";
	      if(count%t.size()==0)
		x=t[t.size()-1];
	      else
	      x=t[count%t.size()-1];
	    }

	  if(s[i]=='5')
	    {
	      string t="jkl";
	      if(count%t.size()==0)
		x=t[t.size()-1];
	      else
	      x=t[count%t.size()-1];
	    }
	  if(s[i]=='6')
	    {
	      string t="mno";
	      if(count%t.size()==0)
		x=t[t.size()-1];
	      else
	      x=t[count%t.size()-1];
	    }
	  if(s[i]=='7')
	    {
	      string t="pqrs";
	      if(count%t.size()==0)
		x=t[t.size()-1];
	      else
	      x=t[count%t.size()-1];
	    }
	  if(s[i]=='8')
	    {
	      string t="tuv";
	      if(count%t.size()==0)
		x=t[t.size()-1];
	      else
	      x=t[count%t.size()-1];
	    }
	  if(s[i]=='9')
	    {
	      string t="wxyz";
	      if(count%t.size()==0)
		x=t[t.size()-1];
	      else
	      x=t[count%t.size()-1];
	    }
	  if(s[i]=='0')
	    {
	      if(count!=0)
		{
		  cout<<x;
		  out=false;
		}
	      count=0;

	    }
	}
      if(!out)
      cout<<endl;
    } 

}

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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	map<char, vector<char>> input;
	input['1'] = {'.', ',', '!', '?', ' '};
	input['2'] = {'a', 'b', 'c'};
	input['3'] = {'d', 'e', 'f'};
	input['4'] = {'g', 'h', 'i'};
	input['5'] = {'j', 'k', 'l'};
	input['6'] = {'m', 'n', 'o'};
	input['7'] = {'p', 'q', 'r', 's'};
	input['8'] = {'t', 'u', 'v'};
	input['9'] = {'w', 'x', 'y', 'z'};
	rep (i, n) {
		string s;
		cin >> s;
		string ans;
		int idx = [&] {
			rep (i, s.size()) {
				if (s[i] != '0') return i; 
			}
			return 0;
		}();
		int cnt = -1;
		REP (i, idx, s.size()) {
			if (i != 0 && s[i] == '0' && s[i - 1] != '0') {
				ans += input[s[i - 1]][cnt];
				cnt = -1;
			} else if (s[i] != '0') {
				cnt = (cnt + 1) % input[s[i]].size();
			}
		}
		cout << ans << 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;
}