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>
using namespace std;
int main(){
  string key[10]={"0",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
  int n;
  cin>>n;
  for (int nn=0;nn<n;nn++){
    string in;
    vector<int> input;
    string ans;
    cin>>in;
    for (int i=0;i<in.length();i++){
      input.push_back(in[i]-48);
    }
    int count=0;
    int cc=0;
    for (int i=0;i<in.length();i++){
      if (input[i]==0&&i!=0&&count!=0){
	char c=key[input[i-1]][(count-1)%key[input[i-1]].size()];
	ans[cc]=c;
	cc++;
	count=0;
	continue;
      }
      else if (input[i]==0&&i==0)
	continue;
      else if (input[i]==0&&count==0)
	continue;
      else
	count++;
    }
    for (int i=0;i<cc;i++){
      cout<<ans[i];
    }
    cout<<endl;
  }
}

C++: #include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using hset = unordered_set<T>;
template<class Key, class T> using hmap = unordered_map<Key, T>;

int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
vector<vector<char> > phone = {
    {},
    {' ', '.', ',', '!', '?'},
    {'c', 'a', 'b'},
    {'f', 'd', 'e'},
    {'i', 'g', 'h'},
    {'l', 'j', 'k'},
    {'o', 'm', 'n'},
    {'s', 'p', 'q', 'r'},
    {'v', 't', 'u'},
    {'z', 'w', 'x', 'y'}
};

int main() {
    int n; cin >> n;
    string s;
    for (int i = 0; i < n; i++) {
        cin >> s;
        int k = 0, kl = 0;
        for (char c : s) {
            if (c - '0' == 0) {
                if (kl == 0) continue;
                cout << phone[kl][k];
                k = 0;
                kl = 0;
            } else {
                kl = c - '0';
                k = (k+1) % phone[kl].size();
            }
        }
        cout << endl;
    }
    return 0;
}

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

using namespace std;

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

int main()
{
	int num = 0; cin >> num;
	string dat[12] = { "", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };
	rep(i, num)
	{
		string str; cin >> str;
		vector<int> hit(10, 0);
		rep(j, (int)str.size())
		{
			hit[str[j] - '0'] += 1;
			if (j == 0 || str[j - 1] == '0') {}
			else if (str[j] == '0')
			{
				int n = 0, tmp = str[j - 1] - '0';
				n = hit[tmp] % (int)dat[tmp].size();
				if (n == 0){ n = hit[tmp] + 1; }
				if (n >= 3 && (int)dat[tmp].size() == 3) { n -= 1; }
				printf("%c", dat[tmp][n - 1]);
				rep(i, 10){ hit[i] = 0; }
			}
		}
		printf("\n");
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const string button[10] = { 
	"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"
};

int main()
{
	ios_base::sync_with_stdio(0);
	int n; cin >> n;
	while (n-- ){
		string s = ""; cin >> s;
		int m =  s.length();
		map<int,int> p; p.clear();
		string res = "";

		rep (i, m ){
			if (s[i] != '0' ){
				p[(int)(s[i]-'0')]++;
			}else{
				map<int,int>::iterator it = p.begin();
				if (it == p.end() ) continue;
				int a = (*it).first;
				int b = (*it).second; b--;
				int len = button[a].length();
				res += button[a][b%len];
				p.clear();
			} // end if
		} // end rep
		cout << res << endl;

	} // end while

	return 0;
}

C++: #include <iostream>
#include <queue>
#include <string>
using namespace std;
int main(){
	string bottun[10] = { "0", ".,!?", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };
	queue<char> str;
	int n, i;
	cin >> n;
	while( n-- > 0 ){
		char s[1025];
		cin >> s;
		for( i = 0; s[i] != '\0'; i++ ){
			str.push(s[i]);
		}
		int t = 0, num;
		while( !str.empty() ){
			if( str.front() == '0' && num != 0 ){
				cout << bottun[num][(t-1)%bottun[num].length()];
				t = -1;
			}
			num = (int)(str.front() - '0');
			str.pop();
			t++;
		}
		cout << endl;
	}
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
	string strs[9]={{".,!?"},{"abc"},{"def"},{"ghi"},{"jkl"},{"mno"},{"pqrs"},{"tuv"},{"wxyz"}};
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string ans="",tmp;
		cin>>tmp;
		int a=0,b=0;//aがb回押された
		for(int j=0;j<tmp.size();j++){
			if(tmp[j]=='0'&&b>=1){
			ans+=strs[a-1][(b+strs[a-1].size()-1)%strs[a-1].size()];
			a=0,b=0;
			}
			if(tmp[j]=='0')continue;
			else {
				a=tmp[j]-'0';
				b++;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <queue>
#include <complex>

#define INF 100000000
#define EPS 1e-9

using namespace std;

typedef long long ll; 

#define MAX_N 31
#define MAX_M 501

int N;

string alpha[10];

vector<string> ans_list;

int main(){
  
  cin >> N;

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

  while(N > 0){
    N--;
    string str, ans;
    cin >> str;
    for(int i = 0; i < str.length(); i++){
      if(str[i] == '0')
	continue;
      int num = 0;
      for(int e = i+1; e < str.length(); e++){
	if(str[i] != str[e]){
	  num = e - i;
	  break;
	}
      }
      ans += alpha[str[i] - '0'][(num-1) % alpha[str[i] - '0'].length()];
      i += num;
    }
    ans_list.push_back(ans);
  }

  for(int i = 0; i < ans_list.size(); i++){
    cout << ans_list[i] << endl;
  }

  return 0;
  
}