Go: package main

import (
	"bytes"
	"fmt"
)

//Ktai has a keyboard and a state.
type Ktai struct {
	keyboard KeyBoard
	textBuf  *bytes.Buffer
}

// KeyBoard is type of a map.
type KeyBoard map[rune]string

// KEYBOARD that Ktai has
var KEYBOARD = KeyBoard{
	'0': "",
	'1': ".,!? ",
	'2': "abc",
	'3': "def",
	'4': "ghi",
	'5': "jkl",
	'6': "mno",
	'7': "pqrs",
	'8': "tuv",
	'9': "wxyz",
}

func main() {
	var N int
	fmt.Scanf("%d", &N)
	ktai := &Ktai{
		KEYBOARD, &bytes.Buffer{},
	}
	for i := 0; i < N; i++ {
		var numstr string
		fmt.Scanf("%s", &numstr)
		ktai.feed(numstr)
		ktai.print()
	}
}

func (ktai *Ktai) feed(str string) {
	var char *byte
	for _, v := range str {
		if v == '0' {
			if char != nil {
				ktai.textBuf.WriteByte(*char)
				char = nil
			}
			continue
		} else {
			runestring := ktai.keyboard[v]
			idx := ktai.indexOf(char, runestring)
			next := (idx + 1) % len(runestring)
			c := runestring[next]
			char = &c
		}
	}
}

func (ktai *Ktai) indexOf(ch *byte, str string) int {
	if ch == nil {
		return -1
	}
	r := rune(*ch)
	idx := -1
	for i, v := range str {
		if r == v {
			idx = i
			break
		}
	}
	return idx
}

func (ktai *Ktai) print() {
	fmt.Println(ktai.textBuf.String())
	ktai.textBuf.Reset()
}

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

int main(){
	int n, len;
	cin >> n;
	for(int i = 0; i < n; ++i){
		string str;
		cin >> str;
		len = str.length();
		string ans;
		char ch = 0;
		for(int j = 0; j < len; ++j){
			if(str[j] == '0' && ch != 0){ 
				ans.push_back(ch);
				ch = 0;
			}else if(str[j] == '1'){
				if(ch == '.'){
					ch = ',';
				}else if(ch == ','){
					ch = '!';
				}else if(ch == '!'){
					ch = '?';
				}else if(ch == '?'){
					ch = ' '; 
				}else{
					ch = '.';
				}
			}else if(str[j] == '2'){
				if(ch == 'a'){
					ch = 'b';
				}else if(ch == 'b'){
					ch = 'c';
				}else{
					ch = 'a';
				}
			}else if(str[j] == '3'){
				if(ch == 'd'){
					ch = 'e';
				}else if(ch == 'e'){
					ch = 'f';
				}else{
					ch = 'd';
				}
				
			}else if(str[j] == '4'){
				if(ch == 'g'){
					ch = 'h';
				}else if(ch == 'h'){
					ch = 'i';
				}else{
					ch = 'g';
				}
			}else if(str[j] == '5'){
				if(ch == 'j'){
					ch = 'k';
				}else if(ch == 'k'){
					ch = 'l';
				}else{
					ch = 'j';
				}
			}else if(str[j] == '6'){
				if(ch == 'm'){
					ch = 'n';
				}else if(ch == 'n'){
					ch = 'o';
				}else{
					ch = 'm';
				}
				
			}else if(str[j] == '7'){
				if(ch == 'p'){
					ch = 'q';
				}else if(ch == 'q'){
					ch = 'r';
				}else if(ch == 'r'){
					ch = 's';
				}else{
					ch = 'p';
				}
			}else if(str[j] == '8'){
				if(ch == 't'){
					ch = 'u';
				}else if(ch == 'u'){
					ch = 'v';
				}else{
					ch = 't';
				}
			}else if(str[j] == '9'){
				if(ch == 'w'){
					ch = 'x';
				}else if(ch == 'x'){
					ch = 'y';
				}else if(ch == 'y'){
					ch = 'z';
				}else{
					ch = 'w';
				}
			}
		}
		cout << ans << endl;
	}
}

C++: 5
20
220
222220
44033055505550666011011111090666077705550301110
000555555550000330000444000080000200004440000

C++: #include<cmath>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cstdio>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define fori(i,k,n) for(int i=k;i<n;i++)
using namespace std;
const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
const int dX[8] = { 0, 1, 1, 1, 0, -1, -1, -1 }, dY[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
/*
(char)'1' - (int)48 = (int)1; 



*/


int main()
{
	int n;
	cin >> n;
	string ans[10] = { ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv","wxyz"};
	while (n--)
	{
		string a;
		cin >> a;
		int now = -1;
		for (int i = 0; i < a.size(); i++)
		{
			int k = a[i] - 48;
			if (k == 0)
			{
				if (now != -1)
				{
					cout << ans[(int)(a[i-1]-49)][(now) % (int)ans[a[i-1]-49].size()];
					now = -1;
				}
			}
			else
			{
				now++;
			}


		}
		cout << endl;
	}
	return 0;
}

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

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

#define MAXLEN 1024

char *renovate(char *s);
char judge(char string, int c){

  if(string == '1'){
    if(c % 5 == 1){
      return '.';
    } else if(c % 5 == 2){
      return ',';
    } else if(c % 5 == 3){
      return '!';
    } else if(c % 5 == 4){
      return '?';
    } else if(c % 5 == 0){
      return ' ';
    }

  } else if(string == '2'){
    if(c % 3 == 1){
      return 'a';
    } else if(c % 3 == 2){
      return 'b';
    } else if(c % 3 == 0){
      return 'c';
    }
  } else if(string == '3'){
    if(c % 3 == 1){
      return 'd';
    } else if(c % 3 == 2){
      return 'e';
    } else if(c % 3 == 0){
      return 'f';
    }
  } else if(string == '4'){
    if(c % 3 == 1){
      return 'g';
    } else if(c % 3 == 2){
      return 'h';
    } else if(c % 3 == 0){
      return 'i';
    }
  } else if(string == '5'){
    if(c % 3 == 1){
      return 'j';
    } else if(c % 3 == 2){
      return 'k';
    } else if(c % 3 == 0){
      return 'l';
    }
  } else if(string == '6'){
    if(c % 3 == 1){
      return 'm';
    } else if(c % 3 == 2){
      return 'n';
    } else if(c % 3 == 0){
      return 'o';
    }
  } else if(string == '7'){
    if(c % 4 == 1){
      return 'p';
    } else if(c % 4 == 2){
      return 'q';
    } else if(c % 4 == 3){
      return 'r';
    } else if(c % 4 == 0){
      return 's';
    }
  } else if(string == '8'){
    if(c % 3 == 1){
      return 't';
    } else if(c % 3 == 2){
      return 'u';
    } else if(c % 3 == 0){
      return 'v';
    }
  } else if(string == '9'){
    if(c % 4 == 1){
      return 'w';
    } else if(c % 4 == 2){
      return 'x';
    } else if(c % 4 == 3){
      return 'y';
    } else if(c % 4 == 0){
      return 'z';
    }
  }

}
  
int main(void){
  char str[MAXLEN + 1];

  fgets(str, MAXLEN, stdin);

  if(str[strlen(str) - 1] == '\n'){
    str[strlen(str) - 1] = '\0';
  }

  cout << renovate(str) << endl;

  return 0;
}

char *renovate(char *s){
  char *answer = (char *)malloc(sizeof(s)), number = ' ';
  int i, j = 0, count = 0;

  for(i = 0; *(s + i) != '\0'; i++){
    if(*(s + i) != '0'){
      if(count == 0){
	number = *(s + i);
	count++;
      } else if(count != 0){
	count++;
      } 
    } else if(*(s + i) == '0'){
      if(number != ' '){
	answer[j++] = judge(number, count);
	count = 0;
	number = ' ';
      }
    }
  }

  answer[j] = '\0';

  return answer;
}