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<cstdio>
#include<iostream>
#include<vector>
#include<string>
using namespace std;

int main() {
	int n;
	vector<vector<char>>boad(10);
	boad[1] = { '.',',','!','?',' ' };
	char c = 'a';
	for (int i = 2; i < 10; ++i) {
		if (i != 7 && i != 9) {
			for (int j = 0; j < 3; ++j) {
				boad[i].push_back(c++);
			}
		}
		else for (int j = 0; j < 4; ++j)boad[i].push_back(c++);
	}
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		char b,pre='0';
		int count = 1;
		int sup = s.length();
		for (int l = 0; l < sup; ++l) {
			b = s[l];
			if (pre != b) {
				int num = pre - '0';
				if (num) printf("%c", boad[num][(count - 1) % boad[num].size()]);
				count = 1;
				pre = b;
			}
			else count++;
		}
		printf("\n");
	}
}

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

using namespace std;

vector<string> ans;
string bot[10] = {"",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
int main(){
	int n;
	cin >> n;
	for(int i = 0;i < n;i++){
		string mess;
		string code;
		cin >> code;
		int count = 0;
		for(int j = 0;j < code.size();j++){
			if(code[j] == '0'){
				if(j == 0 || count == 0) continue;
				int num = 1;
				for(int k = 1;k <= 9;k++){
					if(('0' + k) == code[j-1]){num = k; break;}
				}
				int roop = bot[num].size();
				mess += bot[num][(count - 1)% roop];
				count = 0;
			}else{
				count++;
			}
		}
		ans.push_back(mess);
	}
	
	for(int i = 0;i < n;i++){
		cout << ans[i] << endl;
	}
	return 0;
}

C++: #include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define INF 1000000000
#define rep(i,a,b) for (int i=(a);i<(b);i++)
#define rev(i,a,b) for (int i=(a)-1;i>=b;i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef queue<int> qi;
typedef vector<int> vi;
typedef vector<string> vs;
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };

char c[9][6] = {
	{'.', ',', '!', '?', ' '},
	{'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 n;
	cin >> n;
	rep(i,0,n) {
		string s;
		cin >> s;
		int num = 0;
		string ans = "";
		rep(j,0,s.size()) {
			if(s[j] != '0') num++;
			else {
				if(num == 0) continue;
				char tmp = s[j-1];
				int b = atoi(&tmp)-1;
				if(b == 0) ans += c[b][(num-1)%5];
				else if(b == 6 || b == 8) ans += c[b][(num-1)%4];
				else ans += c[b][(num-1)%3];
				num = 0;
			}
		}
		cout << ans << endl;

	}

	return 0;
}

C++: #include<iostream>
#include<string>
#include<vector>
using namespace std;

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

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

		int pos=0;
		int now=-1;
		int count=0;
		while(pos<s.size()){
			if(s[pos]=='0'){
				if(now<0){pos++;continue;}
				count%=D[now].size();
				cout<<D[now][count];
				count=0;
				pos++;
				now=-1;
			}
			else{
				if(now<0){
					now=s[pos]-'0';
					count=0;
					
				}
				else count++;
				pos++;
			}
		}
		cout<<endl;
	}
	return 0;
}

C++: null

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;
typedef long long int lli;

string charset[10][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 loop[10] = {0, 5, 3, 3, 3, 3, 3, 4, 3, 4};

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

	int N;
	cin >> N;
	vector<string> ansvec;
	for (int n = 0; n < N; n++){
		string s;
		cin >> s;

		int i = 0;
		int push = -1;
		string ans = "";
		while (i < s.length()){
			int num = stoi(s.substr(i, 1));
			if (num != 0){
				int thisnum = num;
				while (num != 0){
					push++;
					i++;
					num = stoi(s.substr(i, 1));
				}
				ans += charset[thisnum][push % loop[thisnum]];
				push = -1;
			}
			i++;
		}
		cout << ans << endl;
		//ansvec.push_back(ans);
	}
/*
	for (auto it = ansvec.begin(); it != ansvec.end(); it++){
		cout << *it << endl;
	}*/
	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
 
string keitai[]{".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
int main(){
	int n;cin>>n;
    string s;
    rep(j,n){
		cin>>s;
        int cnt=0;
        string ans;
        rep(i,s.size()){
            if(s[i]=='0'){
                if(cnt)ans+=keitai[s[i-1]-'1'][(cnt-1)%keitai[s[i-1]-'1'].size()];
                cnt=0;
            }
            else cnt++;
        }
        if(ans!="")cout<<ans<<endl;
    }
}

C++: #include<iostream>
#include<string>
#include<cstring>
using namespace std;

int main(){
  string s;
  int N;
  char bot[10][20]={"0",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"}; 

  int count=0,flag=0;
  while(1){
  cin>>N;
  if(N==0)break;
  for(int i=0;i<N;i++){
    count=0;
    cin>>s;
    for(int j=0;j<(int)s.size();j++){
      if(s[j]!='0'&&flag==0){
	flag=s[j]-'0';
      }else if(flag!=0&&s[j]!='0'){
	count++;
      }else if(s[j]=='0'&&flag!=0){
	if(count<=strlen(bot[flag]))cout<<bot[flag][count];
	else{
	  while(count>strlen(bot[flag])){
	    count=count-strlen(bot[flag]);
	  }
	  cout<<bot[flag][count];
	}
	count=0;
	flag=0;
      }
    }
    cout<<endl;
  }
  }
  return 0;
}