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"bits/stdc++.h"
using namespace std;
using ll = int64_t;

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

    vector<vector<char>> table(10, vector<char>());
    table[1].push_back('.');
    table[1].push_back(',');
    table[1].push_back('!');
    table[1].push_back('?');
    table[1].push_back(' ');
    for (int i = 2; i <= 7; i++) {
        for (int j = 0; j < 3; j++) {
            table[i].push_back('a' + (i - 2) * 3 + j);
        }
    }
    table[7].push_back('s');
    table[8].push_back('t');
    table[8].push_back('u');
    table[8].push_back('v');
    table[9].push_back('w');
    table[9].push_back('x');
    table[9].push_back('y');
    table[9].push_back('z');


    for (int i = 0; i < L; i++) {
        string s;
        cin >> s;

        int kind = -1, num = -1;
        for (char c : s) {
            if (c == '0') {
                if (kind != -1) {
                    printf("%c", table[kind][num % table[kind].size()]);
                }
                kind = -1;
                num = -1;
            } else {
                kind = c - '0';
                num++;
            }
        }
        cout << endl;
    }
}

C++: #include <cstdio>
#include <iostream>
#include <string>
using namespace std;
string s[9]={".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		string ss;
		cin >> ss;
		int cnt=0,now;
		for(int j=0;j<ss.size();j++){
			if(ss[j]-'0'==0){
				if(cnt==0) continue;
				printf("%c",s[now-1][(cnt-1)%s[now-1].size()]);
				cnt=0;
				continue;
			}
			cnt++;
			now=ss[j]-'0';
		}
		printf("\n"); 
	}
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int m;
	cin>>m;
	while(m-->0){
		string s;
		string ans;
		pair<int,int> p;
		cin>>s;
		p.first=0;
		p.second=0;

		for(unsigned int i=0; i<s.length();++i){
			if(s[i]=='0'){
				if(p.second<=0)continue;
				switch(p.first){
					case 1:
						ans+=".,!? "[(p.second-1)%5];
						break;
					case 2:
						ans+="abc"[(p.second-1)%3];
						break;
					case 3:
						ans+="def"[(p.second-1)%3];
						break;
					case 4:
						ans+="ghi"[(p.second-1)%3];
						break;
					case 5:
						ans+="jkl"[(p.second-1)%3];
						break;
					case 6:
						ans+="mno"[(p.second-1)%3];
						break;
					case 7:
						ans+="pqrs"[(p.second-1)%4];
						break;
					case 8:
						ans+="tuv"[(p.second-1)%3];
						break;
					case 9:
						ans+="wxyz"[(p.second-1)%4];
						break;
				}
				p.first=-1;
				p.second=-1;
			}
			p.first=s[i]-'0';
			p.second++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <cstdlib>
#include <sstream>
using namespace std;
int main(){
	int N;
	cin >> N;
	for(int i=0;i<N;i++){
		string key[]={".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
		string input;
		cin>>input;
		stringstream b(input);
		int num=0,count=0;
		while(1){
			char c;
			if(!(b>>c))break;
			int input=c-'0';
			if(input!=0){
				count++;
				num=input;
			}
			else {
				if(count!=0)
					cout<<key[num-1][(count-1)%key[num-1].size()];
				num=0;count=0;
			}
		}
		cout<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
string order;
vector<int> num;
vector<char> word;
int n;
char button[9][4] = {{'.',',','!','?'},{'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%4]); //cout << button[but-1][push%4] << endl;
	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<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(100000,0);
        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;
    }
    return 0;
}