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<cstdio>
#include<cstring>
using namespace std;
int main(){
  char m[9][5]={{'.',',','!','?',' '},
		{'a','b','c','1','1'},
		{'d','e','f','1','1'},
		{'g','h','i','1','1'},
		{'j','k','l','1','1'},
		{'m','n','o','1','1'},
		{'p','q','r','s','1'},
		{'t','u','v','1','1'},
		{'w','x','y','z','1'}};

  int a,count=0,c[100],d;
  char b[100][1024];
  cin>>a;
  for(int i=0;i<a;i++){
    scanf("%s",b[i]);
    c[i]=strlen(b[i]);
    for(int j=0;j<c[i];j++){
      if(b[i][j]!='0')count++;
      else
	if(b[i][j-1]!=0){
	  d=(int)(b[i][j-1])-48;

	  if(d==1)
	    if(count%5!=0)
	      cout<<m[d-1][count%5-1];
	    else cout<<m[d-1][4];

	  else if(d==7 || d==9)
	    if(count%4!=0)
	      cout<<m[d-1][count%4-1];
	    else cout<<m[d-1][3];

	  else
	    if(count%3!=0)
	      cout<<m[d-1][count%3-1];
	    else cout<<m[d-1][2]; 
	  count=0;
	}
    }
    cout<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
using namespace std;

char KeitaiKey[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 N;
string input;
stack<int> bt;

void init(){
  while(!bt.empty()) bt.pop();
}

int main(void){
  cin >> N;
  for(int i = 0; i < N; i++){
    init();
    cin >> input;
    for(int j = 0; j < input.size(); j++){
      if(input[j] == '0' && !bt.empty()){
        int nowbt = bt.top()  - 1;
        int size = bt.size();
        if(nowbt == 7 || nowbt == 9){
          if(size > 4) size = size % 4 - 1;
          else size--;
          cout << KeitaiKey[nowbt][size];
        }else if(nowbt == 0){
          if(size > 5) size = size % 5 - 1;
          else size--;
          cout << KeitaiKey[nowbt][size];
        }else{
          if(size > 3) size = size % 3 - 1;
          else size--;
          cout << KeitaiKey[nowbt][size];
        }
        init();
      }else if(input[j] != '0'){
        bt.push(input[j] - '0') ;
      }
    }
    cout << endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	char a[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 n,b=0,c=0,d=0;
	string s;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;b=d=c=0;
		char ss[40];
			for(int j=0;j<s.size();j++){
				if(s[j]=='0'&&c>0){
					if(s[j-1]=='1')d=c%5-1;
					else if(s[j-1]=='6'||s[j-1]=='8')d=c%4-1;
					else d=c%3-1;
					cout<<a[(int)(s[j-1]-'0'-1)][d];
				c=0;
				}
				else c++;
				}
				cout<<endl;
	}
	return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init));

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

const string code[9] = {".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  ll n;
  cin >> n;
  rep(i,n){
    cin >> s;
    ll cnt = 0,num = 0;
    bool f = false;
    string ans = "";
    rep(j,s.size()){
      if(!f && s[j] != '0'){
        num = s[j] - '0' - 1;
        cnt = 0;
        f = true;
      }
      else{
        if(s[j] == '0'){
          if(f)
            ans += code[num][cnt];
          f = false;
        }
        else{
          ++cnt;
          cnt %= code[num].size();
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<stdlib.h>
#include<vector>

using namespace std;

int main(){
  int n,cnt=0;
  string s,before="",tmp,key;
  vector<string> keys{".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> s;
    if (s.length()==1) {
      cout << endl;
      continue;
    }
    for(int i=0;i<s.length();i++){
      tmp = s[i];
      if (tmp!="0" && tmp==before) cnt++;
      else if (tmp==before) continue;
      else if (tmp=="0"){
        key = keys[atoi(before.c_str())-1][(cnt-1)%(keys[atoi(before.c_str())-1].length())];
        cout << key;
        cnt=0;
        before="0";
      } else {
        before =tmp;
        cnt++;
      } 
    }
    cout << endl;
    
  }
  return 0;
    
}

C++: #include <iostream>
#include <cstring>
#include <cstdlib>
using namespace std;
int main()
{
	int n, i, j, k, c, d, x, a;
	char s[1025], r[76], t[10][6] = {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
	cin >> n;
	for (i = 0; i < n; i++)
	{
		cin >> s;
		for (j = x = a = 0, d = 0; j < strlen(s); j++, d = c)
		{
			c = s[j] - '0';
			if (c == 0 && d != 0)
				r[a] = t[d-1][x%strlen(t[d-1])], a++;
			else if (d == c)
				x++;
			else
				x = 0;
		}
		r[a] = '\0';
		cout << r << endl;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    vector<string> v = {".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv",
                        "wxyz"};
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        int cur = 0;
        string ans;
        while(cur < s.size()){
            while(s[cur] != '0'){
                int cur2 = cur;
                while(s[cur] == s[cur2+1]) cur2++;
                ans += v[s[cur]-'1'][(cur2-cur)%v[s[cur]-'1'].size()];
                cur = cur2+1;
            }
            cur++;
        }
        cout << ans << "\n";
    }
    return 0;
}