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>

#define REP(i, n) for(int i = 0; i < (int) (n); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

char top[8] = {'a', 'd', 'g', 'j', 'm', 'p', 't', 'w'};
char mark[5] = {'.', ',', '!', '?', ' '};

int main(){
  int n;
  cin >> n;
  REP(i, n){
    string line;
    cin >> line;
    int cnt = 0;
    REP(j, line.size()){
      if(line[j] == '0'){
        if(cnt == 0) continue;
        if(line[j-1] == '1')
          cout << mark[(cnt-1)%5];
        else{
          int kind = line[j-1] == '7' or line[j-1] == '9' ? 4 : 3;
          cout << char(top[line[j-1] - '2'] + (cnt - 1) % kind);
        }
        cnt = 0;
      }
      else cnt++;
    }
  cout << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <array>
#include <vector>
#include <math.h>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <queue>

#define MAX 100005
#define ll long long int
using namespace std;

int main(void)
{
	string s; // input
	int n;
	int i, j;

	string an;
	int zero = 0; // zero?????´???

	vector <string> ans;
	queue <char> qu;

	char temp;
	int count = 0;
	char tempm; //mozi???????????????????´?




	cin >> n;

	for (i = 0; i < n; i++) {
		cin >> an;

		for (j = 0; j < an.size(); j++) { //qu?????°?????????
			qu.push(an[j]);

		}



		
		while (qu.empty() == 0) {
			count = 0;
			tempm = 'n'; //?????????


			while (1) {
				temp = qu.front();
				if (temp != '0') {
					tempm = temp;
					count++;
					qu.pop();
				}
				else { //0?????£??????
					qu.pop();
					break;
				}


			}



			if (tempm == '1') { // 1?????¨???
				count = count % 5;

				switch (count) {
				case 1:
					s.push_back('.');
					break;
				case 2:
					s.push_back(',');
					break;
				case 3:
					s.push_back('!');
					break;
				case 4:
					s.push_back('?');
					break;
				case 0:
					s.push_back(' ');
					break;
				}
			}
			else if (tempm == '2') { // 2
				count = count % 3;
				switch (count) {
				case 1:
					s.push_back('a');
					break;
				case 2:
					s.push_back('b');
					break;
				case 0:
					s.push_back('c');
					break;

				}
			}
			else if (tempm == '3') { // 3
				count = count % 3;
				switch (count) {
				case 1:
					s.push_back('d');
					break;
				case 2:
					s.push_back('e');
					break;
				case 0:
					s.push_back('f');
					break;

				}
			}
			else if (tempm == '4') { // 4
				count = count % 3;
				switch (count) {
				case 1:
					s.push_back('g');
					break;
				case 2:
					s.push_back('h');
					break;
				case 0:
					s.push_back('i');
					break;

				}
			}
			else if (tempm == '5') { // 5
				count = count % 3;
				switch (count) {
				case 1:
					s.push_back('j');
					break;
				case 2:
					s.push_back('k');
					break;
				case 0:
					s.push_back('l');
					break;

				}
			}
			else if (tempm == '6') { // 6
				count = count % 3;
				switch (count) {
				case 1:
					s.push_back('m');
					break;
				case 2:
					s.push_back('n');
					break;
				case 0:
					s.push_back('o');
					break;

				}
			}
			else if (tempm == '7') { // 7
				count = count % 4;
				switch (count) {
				case 1:
					s.push_back('p');
					break;
				case 2:
					s.push_back('q');
					break;
				case 3:
					s.push_back('r');
					break;
				case 0:
					s.push_back('s');
					break;

				}
			}
			else if (tempm == '8') { // 8
				count = count % 3;
				switch (count) {
				case 1:
					s.push_back('t');
					break;
				case 2:
					s.push_back('u');
					break;
				case 0:
					s.push_back('v');
					break;

				}
			}
			else if (tempm == '9') { // 9
				count = count % 3;
				switch (count) {
				case 1:
					s.push_back('w');
					break;
				case 2:
					s.push_back('x');
					break;
				case 3:
					s.push_back('y');
					break;
				case 0:
					s.push_back('z');

				}
			}




		}

		ans.push_back(s);
		



		s.clear();
	}

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


	return (0);
}

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INT = 1e9;
const ll LINF = 1e18;

string s;
vector<string> button(10);
void init(){
    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";
}
string solve(){
    string res;
    replace(s.begin(),s.end(),'0',' ');
    s += "#";
    stringstream ss; ss << s;
    while(true){
        string X; ss >> X;
        if(X == "#") break;
        int i = X[0] - '0';
        int j = (X.length()-1)%(int)button[i].length();
        res += button[i][j];
    }
    return res;
}
int main(void){
    cin.tie(0); ios_base::sync_with_stdio(false);
    init();
    int T; cin >> T;
    while(T--){
        cin >> s;
        cout << solve() << endl;
    }
    return 0;
}

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

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

int main(){
    int n;
    scanf("%d\n", &n);

    for(int i = 0; i < n; i++){
        string s;
        getline(cin,s);
        int len = s.length();
        for(int j = 0; j < len; j++){
            int cnt = 0;
            char x = s[j];
            if(x == '0')    continue;
            while(j < len && s[j] == x)    j++, cnt++;
            int tmplen = cell[x-'1'].length();
            cout << cell[x-'1'][(cnt-1+tmplen)%(tmplen)];
        }
        cout << endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
  int n, count = 0;
  string input;
  map<char, string> map;

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

  cin >> n;
  int j = 0, i;
  for(i = 0 ; i < n ; i++){
    cin >> input;
    for(j = 0 ; input[j] == '0' && j < (int)input.length() ; j++);

    for( ; j <  (int)input.length() ; j++){
      if(input[j] == '0'){
	if(input[j-1] == '0')continue;
	string hoge = map[input[j-1]];
	cout << hoge[(count-1)%(hoge.length())];
	count = 0;
      }else{
	count++;
      }
    }
    cout << '\n';
      } 
  
}

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

int compare(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}

int main(void) {
	int n;
	int score[1024];

	while (true) {
		std::cin >> n;
		if (!n) break;

		for (int i = 0; i < n; i++) std::cin >> score[i];

		qsort(score, n, sizeof(int), compare);
		double sum = 0;
		for (int i = 1; i < n - 1; i++) sum += score[i];
		int ave = int(sum / (n-2));
		std::cout << ave << '\n';
	}
	return 0;
}