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(){
	string list[] = {
		" ",".,!? ","abc","def"
		,"ghi","jkl","mno"
		,"pqrs","tuv","wxyz"
	};
	string str,out;
	int times;
	cin >> times;
	for(int i =0 ;i<times;i++){
		cin >> str;
		char cur='1',cash='a';
		int count = 0,idx;
		int n = 0;
		while(n <str.size()){
			cur = str[n];

			if(cur == '0'){
					out +=list[idx][count%=list[idx].size()];
			}
			else if(cur ==cash){
				count +=1;
			}
			else{
				idx= (int)(cur - '0');
			}
			n++;
		}//?????????????????°???????????????
		cout << out << endl;
		out ="";
	}
		return 0;
}

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

int main(){
  vector<vector<char> > v;
  vector<char> mv;

  mv.push_back(' ');mv.push_back('.');mv.push_back(',');mv.push_back('!');mv.push_back('?');
  v.push_back(mv);
  mv.clear();

  mv.push_back('c');mv.push_back('a');mv.push_back('b');
  v.push_back(mv);
  mv.clear();

  mv.push_back('f');mv.push_back('d');mv.push_back('e');
  v.push_back(mv);
  mv.clear();

  mv.push_back('i');mv.push_back('g');mv.push_back('h');
  v.push_back(mv);
  mv.clear();

  mv.push_back('l');mv.push_back('j');mv.push_back('k');
  v.push_back(mv);
  mv.clear();

  mv.push_back('o');mv.push_back('m');mv.push_back('n');
  v.push_back(mv);
  mv.clear();

  mv.push_back('s');mv.push_back('p');mv.push_back('q');mv.push_back('r');
  v.push_back(mv);
  mv.clear();

  mv.push_back('v');mv.push_back('t');mv.push_back('u');
  v.push_back(mv);
  mv.clear();

  mv.push_back('z');mv.push_back('w');mv.push_back('x');mv.push_back('y');
  v.push_back(mv);
  mv.clear();

  string s;
  int a,i,cou,n,cou2,b;
  cin >>b;
  for(int j=0;j<b;j++){ // 入力
    cin>>s;
    a=s.size();
    //cout <<a<< ' ';//////////////////
    i=0;
    cou2=0;
    while(i<a){//改行まで
      cou=0;
      n=0;
      while(s[i]!='0'&&i<a){//０まで
	if(n!=s[i]-'0')cou=0;
	n=s[i]-'0';
	i++;
	cou++;
      }
      i++;
      //cout <<n<< cou<< ' ';/////////////////
      if(cou!=0&&i<=a){
	if(n==8||n==2||n==3||n==4||n==5||n==6)cou=cou%3;
	else if(n==7||n==9)cou=cou%4;
	else if(n==1)cou=cou%5;

	cout<<v[n-1][cou];
	cou2++;
      }
    }
    if(cou2!=0)cout<<endl;
  }
  return 0;
}

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

char mes(char c){
    int n = c -'0';
    if(n==2)return 'a';
    else if(n==3)return 'd';
    else if(n==4)return 'g';
    else if(n==5)return 'j';
    else if(n==6)return 'm';
    else if(n==7)return 'p';
    else if(n==8)return 't';
    else return 'w';
}


int main(){
    long long n;
    cin >> n;
    for(int i=0;i<n;i++){
        string str;
        cin >> str;
        int cou = 0;
        for(int j=1;j<str.size();j++){
            if(str[0]!='0')cou=1;
           if(str[j]=='0' && str[j-1]!='0'){
                if(str[j-1]!='0'){
                    if(cou)cou--;
                    if(str[j-1]!='1'){
                        char a = mes(str[j-1]);
                        if(str[j-1]=='7'||str[j-1]=='9')printf("%c",a + (cou)%4);
                        else printf("%c",a+cou%3);
                    }else{
                       cou%=5;
                        if(!cou)cout << ".";
                        else if(cou==1)cout << ",";
                        else if(cou==2)cout << "!";
                        else if(cou==3)cout << "?";
                        else cout << " ";
                    }
                }
                cou = 0;
           }else if(str[j]!='0'){
               cou++;
           }
        }
        cout << endl;
    }
}

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

#define MAXLEN 1024
#define MAXCHAR 76

char judge(char c, int x){
  int i;

  if(c == '1'){
    i = x % 5;

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

}

void ret_char(char *s, int sp, char *r){
  printf("s = %s\n", s);
  printf("sp = %d\n", sp);

  if(*s != '\0'){
    if(*s == '0'){
      if(sp != 0){
	printf("*(s - 1) = %c, sp = %d\n", *(s - 1), sp);
	*r = judge(*(s - 1), sp);
	printf("%c\n", *r);
	sp = 0;
	s++;
	r++;
	ret_char(s, sp, r); // 再帰
      } else {
	s++;
	ret_char(s, sp, r); // 再帰
      }
    } else {
      s++;
      sp++;
      ret_char(s, sp, r); // 再帰
    }
  }

}

main(){
  int testcase, i, j, count = 0;
  char message[MAXLEN + 1], *rechar = (char *)malloc(sizeof(char) * MAXCHAR);

  cin >> testcase;

  for (i = 0; i < testcase; i++){
    scanf("%s", message);

    message[strlen(message)] = '\0';
    printf("message = %s\n", message);

    ret_char(message, 0, rechar);

    printf("%s\n", rechar);
    strcpy(message, "");
    strcpy(rechar, "");
  }

  return 0;
}

C++: #include<bits/stdc++.h>

using namespace std;

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

int main(){
	
	int n;
	
	cin >> n;
	
	for(int i=0;i<n;i++){
		
		string s;
		
		cin >> s;
		
		int num=0;
		int cnt=0;
		
		for(int j=0;s[j];j++){
			if(s[j]=='0'){
				if(cnt!=0){
					num = s[j-1]-'0';
					cout << c[num][(cnt-1)%c[num].size()];
					cnt=0;
				}
			}else{
				cnt++;
			}
		}
	cout << endl;
	}
				
	return 0;
}