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<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<cstring>
#include<utility>
#include<set>
#include<stack>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX  999999
int main(){
    char ans[][10] = {
        {},
        {'.',',','!','?',' '},
        {'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; cin >> n;
    rep(i,n){
        string s;
        cin >> s;
        int temp = 0;
        int counter =-1 ;
        for(int k = 0;k<s.size();k++){
            int now = int(s[k]-48);
            if(k == 0){temp = now;counter++;}
            else if(now != 0){
                temp = now;counter++;}
            if(now == 0){
                if(temp  == 9 || temp == 7)
                    counter%=4;
                else if(temp != 1&& temp != 7 && temp!= 9)
                    counter%=3;
                else if(temp == 1)
                    counter %=5;
                cout << ans[temp][counter];
                temp = 0;counter =-1;;
            }
        }
        cout << endl;
    }
}

C++: #include<iostream>
#include<string>

using namespace std;

string s[10];

int n;

string decode(string str) {
    int pbt = 0;
    int cnt = 0;
    string res = "";
    for (char c : str) {
        int bt = c - '0';
        if (pbt != 0 && bt == 0) {
            res += s[pbt][(cnt - 1) % s[pbt].size()];
            pbt = 0;
            cnt = 0;
        } else if (bt != 0) {
            pbt = bt;
            cnt++;
        }
   }

   return res;
}

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

    cin >> n;
    for (int i = 0; i < n; ++i) {
        string str;
        cin >> str;
        cout << decode(str) << endl;
    }
}

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

using namespace std;

long long INF=1e15;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin>>n;

    string s1,s2,s3,s4,s5,s6,s7,s8,s9;
    s1=".,!? ";s2="abc";s3="def";s4="ghi";s5="jkl";
    s6="mno";s7="pqrs";s8="tuv";s9="wxyz";
    
    for(int i=0;i<n;i++){
        string S;
        cin>>S;
        int sum=0;
        char c;
        string s;
        bool f=false;
        for(int j=0;j<S.size();j++){
            if(S[j]!='0'){
                f=true;
                c=S[j];
                sum++;
                if(c=='1')s=s1;if(c=='2')s=s2;if(c=='3')s=s3;
                if(c=='4')s=s4;if(c=='5')s=s5;if(c=='6')s=s6;
                if(c=='7')s=s7;if(c=='8')s=s8;if(c=='9')s=s9;
            }
            else{
                sum--;
                if(s==s1)sum%=5;
                else if(s==s7||s==s9)sum%=4;
                else sum%=3;
                if(f)cout<<s[sum];
                sum=0;
                f=false;
            }
        }
        cout<<endl;
    }
}

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

using namespace std;

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

int main(void){
  int n;
  string s;

  cin >> n;
  for(int i=0; i<n; i++){
    vector<char> v;
    cin >> s;

    int count = 0;
    for(int j=0; j<s.size(); j++){
      if(s[j] == '0'){
        if(j == 0 || s[j-1] == '0')
          continue;

        v.push_back(button[(s[j-1]-'0')-1][(count-1)%button[(s[j-1]-'0')-1].size()]);
        count = 0;
      } else {
        count++;
      }
    }

    for(int j=0; j<v.size(); j++){
      cout << v[j];
    }
    cout << endl;
  }

  return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12

int main(void) {
  vector<vector<char>> c;
  c = {{' '},           {'.', ',', '!', '?', ' '},
       {'a', 'b', 'c'}, {'d', 'e', 'f'},
       {'g', 'h', 'i'}, {'h', 'k', 'l'},
       {'m', 'n', 'o'}, {'p', 'q', 'r', 's'},
       {'t', 'u', 'v'}, {'w', 'x', 'y', 'z'}};

  int num;
  cin >> num;
  REP(s, num) {
    string n;
    cin >> n;

    int kind = -1, cnt = 0;
    REP(i, n.size()) {
      if (n[i] == '0') {
        if (kind != -1) {
          cnt = (cnt - 1) % c[kind].size();
          cout << c[kind][cnt];
        }
        kind = -1;
        cnt = 0;
      } else {
        kind = n[i] - '0';
        cnt++;
      }
    }
    cout << endl;
  }

  return 0;
}

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[100000000000][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;
}