#include #include #include #include #define asdigit(c) (c - '0') #define LOG(x) cout << #x << "=" << (x) << endl; #define S1 " +"; #define S2 "+---+"; #define S3 "+ +"; #define D1 " |"; #define D2 "| "; #define D3 "| |"; using namespace std; void analyze_pid(string word); string getdig(int line, int dig); int main(int argc, char **argv) { string word; while (true) { getline(cin, word); if (word == "end") break; analyze_pid(word); cout << "\n" << endl; } cout << "end"; return 0; } void analyze_pid(string word) { int a,b,c,d; const char *cword = word.c_str(); a = asdigit(word[0]); b = asdigit(word[1]); c = asdigit(word[3]); d = asdigit(word[4]); for (int i=0; i<7; i++) { cout << getdig(i,a); cout << " "; cout << getdig(i,b); if (i==2 || i==4) cout << " o "; else cout << " "; cout << getdig(i,c); cout << " "; cout << getdig(i,d); cout << endl; } } string getdig(int line, int dig) { switch(line) { case 0 : if(dig==1) return S1; if(dig==4) return S3; return S2; case 1 : case 2 : switch(dig) { case 1: case 2: case 7: case 3: return D1; case 5: case 6: return D2; case 4: case 8: case 9: case 0: return D3; } case 3 : if(dig==1 || dig ==7) return S1; if(dig==0) return S3; return S2; case 4 : case 5 : switch(dig) { case 1: case 4: case 5: case 7: case 9: case 3: return D1; case 2: return D2; case 6: case 8: case 0: return D3; } case 6 : if(dig==1 || dig ==7 || dig ==4) return S1; return S2; } }