AOJ_0128 Abacus
問題
解法
テーブル作ってやるだけ。
#include <cstdio> using namespace std; const char table[10][9] = { "* = ****", "* =* ***", "* =** **", "* =*** *", "* =**** ", " *= ****", " *=* ***", " *=** **", " *=*** *", " *=**** ", }; int main(){ int n; bool f = false; while(scanf("%d", &n) != EOF){ if(f) puts(""); else f = true; char srbn[8][6]; int r = 10000; for(int i = 0; i < 5; i++){ int t = n/r; n=n%r; r/=10; for(int j = 0; j < 8; j++) srbn[j][i] = table[t][j]; } for(int i = 0; i < 8; i++){ srbn[i][5] = 0; printf("%s\n", &srbn[i][0]); } } return 0; }