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 <stdio.h>
#include <string.h>

// int zero_count(char str[]) {
//   int a;
//   int cnt = 0;
//   a = strlen(str);
//   for (int i = 0; i < a; i++) {
// 	if (str[i] == '0') {
// 	  ctr++;
// 	}
//   }
//   return ctr;
// }

int main(void) {
  int n;
  // int zero_num = 0;
  int i, j, k;

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
	char str[10000] = {0};
	char ans[10000] = {0};
	scanf("%s", str);
	int len;
	// char c;
	len = strlen(str);
	j = 0;
	k = 0;
	int /* zero[100] = {0},*/ one[100] = {0}, two[100] = {0}, three[100] = {0}, four[100] = {0};
	int five[100] = {0}, six[100] = {0}, seven[100] = {0}, eight[100] = {0}, nine[100] = {0};
	int cnt = 0;
	
	while(1) {
	  switch (str[j]) {
	  case '0':
		///////////////////////////////////////////////////////////////////////////////
		if (one[k] != 0) {
		  cnt = one[k] % 5;
		  switch(cnt) {
		  case 1:
			ans[k] = '.';
			break;
		  case 2:
			ans[k] = ',';
			  break;
		  case 3:
			ans[k] = '!';
			break;
		  case 4:
			ans[k] = '?';
			break;
		  case 0:
			ans[k] = ' ';
			break;
		  }
		  k++;
		}
		else if (two[k] != 0) {
		  cnt = two[k] % 3;
		  switch(cnt) {
		  case 1:
			ans[k] = 'a';
			break;
		  case 2:
			ans[k] = 'b';
			  break;
		  case 0:
			ans[k] = 'c';
			break;
		  }
		  k++;
		}
		else if (three[k] != 0) {
		  cnt = three[k] % 3;
		  switch(cnt) {
		  case 1:
			ans[k] = 'd';
			break;
		  case 2:
			ans[k] = 'e';
			  break;
		  case 0:
			ans[k] = 'f';
			break;
		  }
		  k++;
		}
		else if (four[k] != 0) {
		  cnt = four[k] % 3;
		  switch(cnt) {
		  case 1:
			ans[k] = 'g';
			break;
		  case 2:
			ans[k] = 'h';
			  break;
		  case 0:
			ans[k] = 'i';
			break;
		  }
		  k++;
		}
		else if (five[k] != 0) {
		  cnt = five[k] % 3;
		  switch(cnt) {
		  case 1:
			ans[k] = 'j';
			break;
		  case 2:
			ans[k] = 'k';
			  break;
		  case 0:
			ans[k] = 'l';
			break;
		  }
		  k++;
		}
		else if (six[k] != 0) {
		  cnt = six[k] % 3;
		  switch(cnt) {
		  case 1:
			ans[k] = 'm';
			break;
		  case 2:
			ans[k] = 'n';
			  break;
		  case 0:
			ans[k] = 'o';
			break;
		  }
		  k++;
		}
		else if (seven[k] != 0) {
		  cnt = seven[k] % 4;
		  switch(cnt) {
		  case 1:
			ans[k] = 'p';
			break;
		  case 2:
			ans[k] = 'q';
			break;
		  case 3:
			ans[k] = 'r';
			break;
		  case 0:
			ans[k] = 's';
			break;
		  }
		  k++;
		}

		else if (eight[k] != 0) {
		  cnt = eight[k] % 3;
		  switch(cnt) {
		  case 1:
			ans[k] = 't';
			break;
		  case 2:
			ans[k] = 'u';
			break;
		  case 0:
			ans[k] = 'v';
			break;
		  }
		  k++;
		}
		else if (nine[k] != 0) {
		  cnt = nine[k] % 4;
		  switch(cnt) {
		  case 1:
			ans[k] = 'w';
			break;
		  case 2:
			ans[k] = 'x';
			break;
		  case 3:
			ans[k] = 'y';
			break;
		  case 0:
			ans[k] = 'z';
			break;
		  }
		  k++;
		}
		////////////////////////////////////////////////////////////
		break;
	  case '1':
		one[k]++;
		break;
	  case '2':
		two[k]++;
		break;
	  case '3':
		three[k]++;
		break;
	  case '4':
		four[k]++;
		break;
	  case '5':
		five[k]++;
		break;
	  case '6':
		six[k]++;
		break;
	  case '7':
		seven[k]++;
		break;
	  case '8':
		eight[k]++;
		break;
	  case '9':
		nine[k]++;
		break;
	  }
	  j++;
	  if (len == j) break;
	}
   
	printf("%s\n", ans);
  }



		
   
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
int main(){

  int m;
  cin>>m;
  REP(i,m){
    string str;
    int num[5000]={0};
    char now;
    int out=0;
    char one[5]={'.',',','!','?',' '};
    cin >> str;
    int hoge = str.size();
    REP(i,hoge){
      num[i] = str[i] - '0';
    };
    REP(c,hoge){
      int k=0;
      if(num[c]==1){
	while(num[c]==1){
	  k++;
	  c++;
	}
	out=(k+4)%5;
	cout << one[out];
      }else if(num[c]==2){
	while(num[c]==2){
	  k++;
	  c++;
	}
	out=(k+2)%3;
	now = 'a'+out;
	cout << now;
      }else if(num[c]==3){
	while(num[c]==3){
	  k++;
	  c++;
	}
	out=(k+2)%3;
	now = 'd'+out;
	cout << now;
      }else if(num[c]==4){
	while(num[c]==4){
	  k++;
	  c++;
	}
	out=(k+2)%3;
	now = 'g'+out;
	cout << now;
      }else if(num[c]==5){
	while(num[c]==5){
	  k++;
	  c++;
	}
	out=(k+2)%3;
	now = 'j'+out;
	cout << now;
      }else if(num[c]==6){
	while(num[c]==6){
	  k++;
	  c++;
	}
	out=(k+2)%3;
	now = 'm'+out;
	cout << now ;
      }else if(num[c]==7){
	while(num[c]==7){
	  k++;
	  c++;
	}
	out=(k+3)%4;
	now = 'p'+out;
	cout << now;
      } else if(num[c]==8){
	while(num[c]==8){
	  k++;
	  c++;
	}
	out=(k+2)%3;
	now = 't'+out;
	cout << now;
      }else if(num[c]==9){
	while(num[c]==9){
	  k++;
	  c++;
	}
	out=(k+3)%4;
	now = 'w'+out;
	cout << now;
      }
    }
      cout << endl;
  }}

C++: #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long ll;
typedef std::pair<int,int> pii;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main() {
    int n;cin>>n;
    vector<vector<char>> v={{},{'.',',','!','?',' '},{'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'}};
    bool f=false;
    rep(j,0,n){
        string s;
        cin>>s;
        int x,t=-1;
        rep(i,0,s.length()){
            if(!f){
                f=true;
                x=s[i]-'0';
            }
            
            if(s[i]!='0'){
                t++;
                if(x==9||x==7){
                    if(t==4)t=0;
                }else if(x==1){
                    if(t==5)t=0;
                }else{
                    if(t==3)t=0;
                }
            }else {
                if(t!=-1)cout<<v[x][t];
                f=false;
                t=-1;
            }
        }
        cout<<endl;
    }
    return 0;
}