Go: package main

import (
	"bufio"
	"fmt"
		"os"
	"strconv"
	"strings"
	)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	table := [10]string{
		"* = ****",
		"* =* ***",
		"* =** **",
		"* =*** *",
		"* =**** ",
		" *= ****",
		" *=* ***",
		" *=** **",
		" *=*** *",
		" *=**** ",
	}
	for scanner.Scan() {
		tmp := strings.Split(fmt.Sprintf("%05s", scanner.Text()), "")
		ans := make([]string, 0)
		for _, v := range tmp {
			iv, _ := strconv.Atoi(v)
			ans = append(ans, table[iv])
		}
		for i := 0; i < 8; i++ {
			for j := 0; j < 5; j++ {
				fmt.Print(string(ans[j][i]))
			}
			fmt.Println()
		}
	}
}

Python: from sys import stdout


def upper(n):
    if n < 5:
        return ['*', ' ']
    else:
        return [' ', '*']


def lower(n):
    m = n % 5
    return ['*'] * m + [' '] + ['*'] * (4 - m)


def abacus(n):
    return upper(n) + ['='] + lower(n)


res = []
while True:
    ns = map(int, ('00000' + raw_input().strip())[-5:])
    if ns == [0, 0, 0, 0, 0]:
        break

    ab = []
    for n in ns:
        ab.append(abacus(n))

    for i in range(8):
        for j in range(5):
            res.append(ab[j][i])
        res.append('\n')
    res.append('\n')

stdout.write(''.join(res[:-2]))

Python: # AOJ 0128 Abacus
# Python3 2018.6.19 bal4u

abacus = [
	[ '*', '*', '*', '*', '*', ' ', ' ', ' ', ' ', ' ' ],
	[ ' ', ' ', ' ', ' ', ' ', '*', '*', '*', '*', '*' ],
	[ '=', '=', '=', '=', '=', '=', '=', '=', '=', '=' ],
	[ ' ', '*', '*', '*', '*', ' ', '*', '*', '*', '*' ],
	[ '*', ' ', '*', '*', '*', '*', ' ', '*', '*', '*' ],
	[ '*', '*', ' ', '*', '*', '*', '*', ' ', '*', '*' ],
	[ '*', '*', '*', ' ', '*', '*', '*', '*', ' ', '*' ],
	[ '*', '*', '*', '*', ' ', '*', '*', '*', '*', ' ' ]]
ans = [[0 for c in range(5)] for r in range(8)]

first = True
while True:
	try: n = list(input())
	except: break
	for i in range(5-len(n)):
		for r in range(8): ans[r][i] = abacus[r][0]
	for i in range(len(n)):
		for r in range(8): ans[r][5-len(n)+i] = abacus[r][int(n[i])]
	if first: first = False
	else: print()
	for r in range(8): print(*ans[r])

Python: from sys import stdout


def upper(n):
    if n < 5:
        return ['*', ' ']
    else:
        return [' ', '*']


def lower(n):
    m = n % 5
    return ['*'] * m + [' '] + ['*'] * (4 - m)


def abacus(n):
    return upper(n) + ['='] + lower(n)


while True:
    ns = map(int, ('00000' + raw_input().strip())[-5:])
    if ns == [0, 0, 0, 0, 0]:
        break

    ab = []
    for n in ns:
        ab.append(abacus(n))

    res = []
    for i in range(8):
        for j in range(5):
            res.append(ab[j][i])
        res.append('\n')
    res.append('\n')

    stdout.write(''.join(res[:-2]))

C++: #include <iostream>
#include <string>
using namespace std;
int main() {
	string s, ans[10] = {
		"* = ****",
		"* =* ***",
		"* =** **",
		"* =*** *",
		"* =**** ",
		" *= ****",
		" *=* ***",
		" *=** **",
		" *=*** *",
		" *=**** "
	};
	while(cin >> s) {
		while(s.size() < 5) {
			s = '0' + s;
		}
		for(int i = 0; i < 8; ++i) {
			for(int j = 0; j < 5; ++j) {
				cout << ans[s[j] - '0'].at(i);
			}
			cout << endl;
		}
	}
}

C++: #include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

string str;
char res[8][5];

string conv[10] = {
  "* = ****",
  "* =* ***",
  "* =** **",
  "* =*** *",
  "* =**** ",
  " *= ****",
  " *=* ***",
  " *=** **",
  " *=*** *",
  " *=**** "
};

int main() {
  bool start = true;
  while (cin >> str) {
    if (!start) cout << endl;
    while (str.size() < 5) str = "0" + str;
    for (int i = 0; i < 5; ++i) {
      int j = str[i] - '0';
      for (int k = 0; k < conv[j].size(); ++k) {
	res[k][i] = conv[j][k];
      }
    }
    for (int i = 0; i < 8; ++i) {
      for (int j = 0; j < 5; ++j) {
	cout << res[i][j];
      }
      cout << endl;
    }
    start = false;
  }
}

C++: #include<iostream>

using namespace std;
string str,ans;
char t[8][5];

void write(int x,int num){
  if(num>=5){
    t[0][x]=' ';t[1][x]='*';
  }else{
    t[0][x]='*';t[1][x]=' ';
  }
  t[2][x]='=';
  
  
  for(int i=3;i<8;i++)t[i][x]='*';
  t[3+num%5][x]=' ';
}

int main(){
  int z;
  string str;
  cin>>str;
  while(1){
    z=5-str.size();
    for(int i=0;i<z;i++){
      write(i,0);
    }
    for(int i=0;i<(int)str.size();i++){
      write(i+z,str[i]-'0');
    }
    for(int i=0;i<8;i++){
      for(int j=0;j<5;j++){
	cout<<t[i][j];
      }
      cout<<endl;
    }
    if(cin>>str){}else break;
    cout<<endl;
  }
}

C++: #include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;

int main()
{
    string s;
    string soro[10] = {"* = ****",
"* =* ***",
"* =** **",
"* =*** *",
"* =**** ",
" *= ****",
" *=* ***",
" *=** **",
" *=*** *",
" *=**** "};
    bool flag = true;
    while(cin >> s)
    {
        vector<char> c;
 
        rep(i,5-s.size())
        {
            c.push_back('0');
        }
 
        rep(i,s.size())
        {
            c.push_back(s[i]);
        }
 
        if(flag)
        {
            flag = false;
        }
        else
        {
            cout << endl;
        }
 
        rep(i,8)
        {
            rep(j,5)
            {
                cout << soro[c[j]-'0'][i];
            }
            cout << endl;
        }
    }
    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
#include <sstream>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;

char aba[8][5];

int abac(int n,int i){
	if(n>4){
		aba[0][i]=' ';
		aba[1][i]='*';
		n-=5;
	}else{
		aba[0][i]='*';
		aba[1][i]=' ';
	}
	aba[2][i]='=';
	for(int j=3;j<8;j++){
		if(j-3==n)aba[j][i]=' ';
		else aba[j][i]='*';
	}
}

main(){
	char num[6];
	int flag=0;
	while(cin>>num){
		if(flag)cout<<endl;
		flag=1;
		int s=strlen(num);
		for(int i=0;i<5;i++){
			if(s-5+i<0)abac(0,i);
			else abac(num[s-5+i]-'0',i);
		}
		for(int i=0;i<8;i++){
			for(int j=0;j<5;j++){
				cout<<aba[i][j];
			}
			cout<<endl;
		}
	}
}