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

vector<vector<char>> sett = {
  {'.', ',', '!', '?', ' '},
  {'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;
  vector<string> anss;
  for(int i = 0 ; i < N ; i++){
    string inp; cin >> inp;
    string ans;
    int count = 0;
    int pre = 0;
    for(int j = 0 ; j < sizeof(inp); j++){
      if(inp[j] == '0'){
        if(count == 0) continue;
        ans.push_back(sett[pre-1][(count-1)%sett[pre-1].size()]);
        count = 0;
      }
      else{
        pre = inp[j] - '0';
        count++;
      }
    }
    anss.push_back(ans);
  }
  for(int i = 0 ; i < N ; i++){
      cout << anss[i] << endl;
  }
}

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", "uv", "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>
#include <string>
using namespace std;

int main(){
	int n;
	string m;
	string word[10] = { ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> m;
		int btn = 0;
		int cnt = 0;
		for (int j = 0; j < m.length(); j++){
			if (m[j] != '0'){
				btn = (int)(m[j] - '0');
				cnt++;
			}
			else{
				if (cnt > 0){
					switch (btn){
					case 1:
						cnt = cnt % 6;
						cout << word[btn - 1][cnt-1];
						cnt = 0;
						break;
					case 7:
					case 9:
						cnt = cnt % 5;
						cout << word[btn - 1][cnt-1];
						cnt = 0;
						break;
					case 2:
					case 3:
					case 4:
					case 5:
					case 6:
					case 8:
						cnt = cnt % 4;
						cout << word[btn - 1][cnt-1];
						cnt = 0;
						break;
					}
				}
			}
		}
		cout << endl;
	}
}

C++: #include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;


int main() {
	int n;
	vs button(10, "");
	vi buttonnum(10, 0);

	button[0] = "";
	button[1] = ".,!? ";
	button[2] = "abc";
	button[3] = "def";
	button[4] = "ghi";
	button[5] = "jkl";
	button[6] = "mno";
	button[7] = "pqrs";
	button[8] = "tuv";
	button[9] = "wxyz";

	while(cin >> n, n) {
		REP(k, n) {
			string input;
			cin >> input;
			string output = "";
			int size = input.size();
			int lastnum = 0;

			REP(i, size) {
				switch(input[i]) {
				case '0':
					if(lastnum) {
						output += button[lastnum][(buttonnum[lastnum]-1)%button[lastnum].size()];
						buttonnum[lastnum] = 0;
						lastnum = 0;
						break;
					}
				case '1':
				case '2':
				case '3':
				case '4':
				case '5':			
				case '6':			
				case '7':			
				case '8':			
				case '9':
					++buttonnum[input[i]-'0'];
					lastnum = input[i]-'0';
					break;
				}
			}

			cout << output << endl;
	
		}	
	}
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;


const ll mod = 1000000007;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
// bool debug=false;

/*---------------------------------------------------*/

// _key[何番目のボタンを押したか][何回押したか]
/*
 * ex) k番目のボタンをn回押した時
 *     _key[k - 1][n % _key[k - 1].size()]
 *           ↑           ↑
 *  0が基準なので-1する　↑
 *                       ↑
 *                       ↑
 *       n % _key[k - 1].size() で結果何番目の文字になったかが分かる
 */
 
string _key[9] = {
	      ".,!? ",
	      "abc",
	      "def",
	      "ghi",
	      "jkl",
	      "mno",
	      "pqrs",
	      "tuv",
	      "wxyz"
};

int main(){
  int N;
  cin >> N;
  for(int _ = 0; _ < N; _++) {
    string s, message = "";
    cin >> s;
    int cnt = 0;
    char key = '0';
    
    for(int i = 0; i < s.size(); i++) {
      if(key == '0' && s[i] != '0') {
	cnt = 0;
	key = s[i];
      } else if(key == s[i]) {
	cnt++;
      } else if(s[i] == '0') {
	message += _key[key - '0' - 1][cnt % _key[key - '0' - 1].size()];
	key = '0';
      }
    }
    
    cout << message << endl;
  }
  return 0;
}

C++: #include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>


int main()
{
	int i,j,k;
	int n,m;
	int a[10]={0}; //押された回数
	int b[10]={0,5,3,3,3,3,3,4,3,4}; //割り算	 
	int c; //押されたボタン
	char d[5][10]={
	{'0',' ','c','f','i','l','o','s','v','z'},
	{'0','.','a','d','g','j','m','p','t','w'},
	{'0',',','b','e','h','k','n','q','u','x'},
	{'0','!','0','0','0','0','0','r','0','y'},
	{'0','?','0','0','0','0','0','0','0','0'}};
	char e[1025];
	
	scanf("%d",&n);

	for(i=0;i<n;i++)
	{
		scanf("%s",e);
		for(j=0;j<10;j++){a[j]=0;}
		for(j=0;j<strlen(e);j++)
		{
			if(e[j]=='0'){
				printf("%c",d[a[c]%b[c]][c]);
				a[c]=0;
			}else
			{
				if(e[j]=='1')c=1;
				else if(e[j]=='2')c=2;
				else if(e[j]=='3')c=3;
				else if(e[j]=='4')c=4;
				else if(e[j]=='5')c=5;
				else if(e[j]=='6')c=6;
				else if(e[j]=='7')c=7;
				else if(e[j]=='8')c=8;
				else if(e[j]=='9')c=9;
				a[c]++;
			}
		}
		printf("\n");
	}

	return 0;
}