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 <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
using namespace std;
int main(void){
    vector<string> str(9);
    str[0]=".,!? ";
    str[1]="abc";
    str[2]="def";
    str[3]="ghi";
    str[4]="jkl";
    str[5]="mno";
    str[6]="pqrs";
    str[7]="tuv";
    str[8]="wxyz";
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        string x;
        string ans="";
        cin >> x;
        int count;
        if(x[0]!='0'){
            count=1;
        }else{
            count=0;
        }
        
        for(int j=1;j<x.length();j++){
            if(x[j]=='0'){
                if(x[j-1]!='0'){
                    if(count > str[(x[j-1]-'0')-1].length()){
                        count = count%str[(x[j-1]-'0')-1].length();
                        if(count == 0){
                            count =str[(x[j-1]-'0')-1].length();
                        }
                    }
                    ans+=str[(x[j-1]-'0')-1][count-1];
                }
                count=0;
            }else{
                count++;
            }
        }
        cout << ans << endl;
    }
}

C++: #include<stdio.h>
#include<iostream>
#include<string>

using namespace std;

int main(){

	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		string str;
		char last;
		char key[10][13]={
			{' '},
			{' ','.',',','!','?',' '},
			{' ','a','b','c','a','b','c','a','b','c','a','b','c'},
			{' ','d','e','f','d','e','f','d','e','f','d','e','f'},
			{' ','g','h','i','g','h','i','g','h','i','g','h','i'},
			{' ','j','k','l','j','k','l','j','k','l','j','k','l'},				
			{' ','m','n','o','m','n','o','m','n','o','m','n','o'},
			{' ','p','q','r','s','p','q','r','s','p','q','r','s'},
			{' ','t','u','v','t','u','v','t','u','v','t','u','v'},
			{' ','w','x','y','z','w','x','y','z','w','x','y','z'},								
		};
		cin >> str;
		int array[10],i;
		for(i=0;i<10;i++){
			array[i]=0;
		}
		last = str[0];
		for(i=0;i<str.size();i++){
			array[str[i]-0x30]++;
			if(array[str[i]-0x30] > 12 && last!=1) array[str[i]-0x30]=1;
			if(array[1] > 5) array[1]=1;
			if(str[i]=='0' && last!='0'){
				// cout << last << ':' << array[last-0x30] << endl;
				cout <<  key[(last-0x30)][array[last-0x30]];
				for(int l=0;l<10;l++){
					array[l]=0;
				}
			}
			last = str[i];
		}
		cout << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main() {
    vector<string> v;
    v.push_back("");
    v.push_back(".,!? ");
    v.push_back("abc");
    v.push_back("def");
    v.push_back("ghi");
    v.push_back("jkl");
    v.push_back("mno");
    v.push_back("pqrs");
    v.push_back("tuv");
    v.push_back("wxyz");
    string s;
    int n;
    scanf("%d",&n);
    for(int k=0;k<n;k++) {
        cin>>s;
        int num=0,cnt=0;
        for(int i=0;i<s.size();i++) {
            if(s[i]=='0') {
                if(num) putchar(v[num][(cnt-1)%v[num].size()]);
                num=cnt=0;
            }else {
                num=s[i]-'0';
                cnt++;
            }
        }
        putchar('\n');
    }
}

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

using namespace std;

int main(){
	int n;
	cin >> n;
	while(n--){
		string s; cin >> s;
		string t[] = {" ", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
		string res = "";
		int cnt = 0, idx = 0;
		for(int i=0;i<s.size();i++){
			if(s[i]=='0'){
				if(idx!=0){
					res += t[idx][cnt];
				}
			}
			if(idx == s[i]-'0'){
				cnt = (cnt+1)%t[idx].size();
			} else {
				cnt = 0;
			}
			idx = s[i]-'0';
		}
		cout << res << endl;
	}
}

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

void Show_message(char button, int num)
{
  switch(button)
  {
    case '1':
      switch(num % 5)
      {
        case 1:
          cout << '.'; break;
        case 2:
          cout << ','; break;
        case 3:
          cout << '!'; break;
        case 4:
          cout << '?'; break;
        case 0:
          cout << ' '; break;
      }
      break;
    case '2':
      switch(num % 3)
      {
        case 1:
          cout << 'a'; break;
        case 2:
          cout << 'b'; break;
        case 0:
          cout << 'c'; break;
      }
      break;
    case '3':
      switch(num % 3)
      {
        case 1:
          cout << 'd'; break;
        case 2:
          cout << 'e'; break;
        case 0:
          cout << 'f'; break;
      }
      break;
    case '4':
      switch(num % 3)
      {
        case 1:
          cout << 'g'; break;
        case 2:
          cout << 'h'; break;
        case 0:
          cout << 'i'; break;
      }
      break;
    case '5':
      switch(num % 3)
      {
        case 1:
          cout << 'j'; break;
        case 2:
          cout << 'k'; break;
        case 0:
          cout << 'l'; break;
      }
      break;
    case '6':
      switch(num % 3)
      {
        case 1:
          cout << 'm'; break;
        case 2:
          cout << 'n'; break;
        case 0:
          cout << 'o'; break;
      }
      break;
    case '7':
      switch(num % 4)
      {
        case 1:
          cout << 'p'; break;
        case 2:
          cout << 'q'; break;
        case 3:
          cout << 'r'; break;
        case 0:
          cout << 's'; break;
      }
      break;
    case '8':
      switch(num % 3)
      {
        case 1:
          cout << 't'; break;
        case 2:
          cout << 'u'; break;
        case 0:
          cout << 'v'; break;
      }
      break;
    case '9':
      switch(num % 4)
      {
        case 1:
          cout << 'w'; break;
        case 2:
          cout << 'x'; break;
        case 3:
          cout << 'y'; break;
        case 0:
          cout << 'z'; break;
      }
      break;
  }
}

int main(void)
{
  int n;
  cin >> n;
  char buf_ch;
  cin >> noskipws;
  cin >> buf_ch;
  for (int i = 0; i < n; ++i)
  {
    while (true)
    {
      cin >> buf_ch;
      if (buf_ch == '\n') break;
      if (buf_ch == '0') continue;

      int sum = 1;
      char button = buf_ch;
      while (true)
      {
        cin >> buf_ch;
        if (buf_ch == '0')
        {
          Show_message(button, sum);
          break;
        }
        else
        {
          ++sum;
        }
      }
    }
    cout << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int n;
	cin>>n;
	string a,d[9];
	d[0]=" ,!?",d[1]="abc",d[2]="def",d[3]="ghi",d[4]="jkl";
	d[5]="mno",d[6]="pqrs",d[7]="tuv",d[8]="wxyz";
	for(int i=0;i<n;i++){
		cin>>a;
		int count=-1;
		for(int j=0;j<a.size();j++){
			if(j!=0){
			if(a[j]=='0'&&a[j-1]!='0'){
				cout<<d[a[j-1]-'1'][count];
			    count=-1;
			}
			}
			if(a[j]!='0')
			    count++;
			if(a[j]=='1'||a[j]=='7'||a[j]=='9')
				count%=4;
			else
				count%=3;
		}
		cout<<endl;
	}
    return 0;
}