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;
#define int long long
signed main(){
 string a[9] = {".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
 int n;
 cin >> n;
 for(int k=0; k<n; k++){
   string s;
   cin >> s;
   for(int i=0; i<(int)s.size(); i++){
     char c = s[i];
     int count = 0;
     for(i=i+1; i<(int)s.size(); i++){
       if(s[i] != c) break;
       count++;
    }
    i--;
    if(c=='0') continue;
    int num = c-'0'-1;
    int tmp = count % a[num].size();
    cout << a[num][tmp];
    }
    cout << endl;
 }
 return 0;
}

C++: #include<cstdio>
int main(){
	char C[10][6]={{},{'.',',','!','?',' ', 5 },{'a','b','c', 0 , 0 , 3 },{'d','e','f', 0 , 0 , 3 },{'g','h','i', 0 , 0 , 3 },{'j','k','l', 0 , 0 , 3 },{'m','n','o', 0 , 0 , 3 },{'p','q','r','s', 0 , 4 },{'t','u','v', 0 , 0 , 3 },{'w','x','y','z', 0 , 4 }},s[1025],c;
	int n,i,p;
	scanf("%d",&n);
	for(i=n;p=-1,scanf("%s",s),i;puts(""),--i){
		for(n=0;s[n];++n)
			(s[n]-48)?
				p++
			:
				p=-1,c=0,!c?printf("%c",C[s[n]-48][p%C[s[n]-48][5]]):0;

	}
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[1080], b[1080];
int n, m;

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

char _str[10800];
void output(int val, int cnt){
	if(val == 0)return;
	cout << button[val][(cnt-1) % button[val].size()];
}


int main(){
	while(~scanf(" %s", _str)){
		str = _str;
		int val = 0;
		int cnt = 0;
		for(int i = 0;i < str.size();i++){
			if(str[i] == '0'){
				output(val, cnt);
				val = cnt = 0;
			}
			else{
				val = str[i] - '0';
				cnt++;
			}
		}
		output(val, cnt);
		cout << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  V<string> c(10);
  c[1] = ".,!? ";
  c[2] = "abc";
  c[3] = "def";
  c[4] = "ghi";
  c[5] = "jkl";
  c[6] = "mno";
  c[7] = "pqrs";
  c[8] = "tuv";
  c[9] = "wxyz";
  int q; cin >> q;
  while (q--) {
    string s; cin >> s;
    int n = s.size();
    string res;
    char curr = 0;
    int j = 0;
    for (int i = 0; i < n; ++i) {
      if (s[i] == '0') {
        if (curr) res += curr;
        curr = 0;
        j = 0;
      } else {
        curr = c[s[i] - '0'][j++ % c[s[i] - '0'].size()];
      }
    }
    cout << res << '\n';
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string str,one=".,!? ",ans;
		cin>>str;
		for(int j=0,co=0,num=0;j<=str.size();j++){
			if(num==str[j]-'0')co++;
			else{
				if(num==1)ans+=one[co%5];
				else if(num==7)ans+=co%4+'p';
				else if(num==8)ans+=co%3+'t';
				else if(num==9)ans+=co%4+'w';
				else if(num>1)ans+=co%3+'a'+3*(num-2);
				co=0;
				num=str[j]-'0';
			}
		}
		cout<<ans<<endl;
	}
}

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

#define REP(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
    string keitai[10] =
        {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
    string str;
    int n; cin >> n;
    REP(k,n){
        cin >> str;
        int len = str.size();
        int cur=0, cnt=0;
        int tmp;
        REP(i,len){
            if(str[i]=='0'){ //00???????????¨???cnt=0
                if(cnt!=0){
                    if(cnt % keitai[cnt].size()==0){
                        tmp = keitai[cnt].size() - 1;
                    }else{
                        tmp = cnt % keitai[cnt].size() - 1;
                    }
                    cout << keitai[cur][tmp];
                }
                cur=0; cnt=0;
            }else{ //str[i]!='0'
                if(cur==0){//0??\?????\????????????
                    cur = str[i] - '0';
                    cnt++;
                }else{
                    cnt++;
                }
            }
        }
        cout << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
 
int main() {
    int n,m,a[10] = {0,0,0,0,0,0,0,0,0,0};
    string s,t;
    string s1(".,!? ");
    string s2("abc");
    string s3("def");
    string s4("ghi");
    string s5("jkl");
    string s6("mno");
    string s7("pqrs");
    string s8("tuv");
    string s9("wxyz");
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> s;
        for(int j = 0;j < s.size();j++){
            if(s[j] == '0' && a[1]+a[2]+a[3]+a[4]+a[5]+a[6]+a[7]+a[8]+a[9] == 0)continue;
            else if(s[j] == '1'){
                t = s1;
                m = 1;
                a[1]++;
            }else if(s[j] == '2'){
                t = s2;
                m = 2;
                a[2]++;
            }else if(s[j] == '3'){
                t = s3;
                m = 3;
                a[3]++;
            }else if(s[j] == '4'){
                t = s4;
                m = 4;
                a[4]++;
            }else if(s[j] == '5'){
                t = s5;
                m = 5;
                a[5]++;
            }else if(s[j] == '6'){
                t = s6;
                m = 6;
                a[6]++;
            }else if(s[j] == '7'){
                t = s7;
                m = 7;
                a[7]++;
            }else if(s[j] == '8'){
                t = s8;
                m = 8;
                a[8]++;
            }else if(s[j] == '9'){
                t = s9;
                m = 9;
                a[9]++;
            }
            else if(s[j] == '0' && a[1]+a[2]+a[3]+a[4]+a[5]+a[6]+a[7]+a[8]+a[9] != 0){
                if(m == 1){
                    cout << t[(a[m]-1)%5];
                    a[m] = 0;
                }
                else if(m == 7 || m == 9){
                    cout << t[(a[m]-1)%4];
                    a[m] = 0;
                }
                else{
                    cout << t[(a[m]-1)%3];
                    a[m] = 0;
                }
            }
        }
        cout << endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;int main(){int n,b[]={1,5,3,3,3,3,3,4,3,4},m,i;string s;char t[20][6]={" ",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};cin>>n;while(cin>>s){for(i=m=0;i<s.size();i++)if(s[i]=='0'){if(m)cout<<t[s[i-1]-'0'][(m-1)%b[s[i-1]-'0']];m=0;}else
m++;cout<<endl;}return 0;}