题目:http://poj.org/problem?id=1102
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 15752 | Accepted: 6291 |
Description
Input
Output
Sample Input
2 12345 3 67890 0 0
Sample Output
-- -- -- | | | | | | | | | | | | -- -- -- -- | | | | | | | | | | -- -- -- --- --- --- --- --- | | | | | | | | | | | | | | | | | | | | | | | | --- --- --- | | | | | | | | | | | | | | | | | | | | | | | | --- --- --- ---分析:是的,这就是一道模拟题,仅此而已。需要细心。我是先把8按照尺寸要求写出来,然后其他数字再在8的基础上抹去某些笔画,再保存该数字。
#include <iostream> #include <cstdio> #include <cstring> using namespace std; int s; char n[20],eight[35][20],str[35][20]; void printblank(){ for(int i=0;i<2*s+3;i++) printf(" \n"); } void createight(){ memset(eight,0,sizeof(eight)); eight[0][0]=' '; for(int j=1;j<s+1;j++) eight[0][j]='-'; eight[0][s+1]=' '; for(int i=1;i<s+1;i++){ eight[i][0]='|'; for(int j=1;j<s+1;j++) eight[i][j]=' '; eight[i][s+1]='|'; } eight[s+1][0]=' '; for(int j=1;j<s+1;j++) eight[s+1][j]='-'; eight[s+1][s+1]=' '; for(int i=s+2;i<2*s+2;i++){ eight[i][0]='|'; for(int j=1;j<s+1;j++) eight[i][j]=' '; eight[i][s+1]='|'; } eight[2*s+2][0]=' '; for(int j=1;j<s+1;j++) eight[2*s+2][j]='-'; eight[2*s+2][s+1]=' '; } void clear(int p){ if(p==1) for(int j=0;j<s+2;j++) str[0][j]=' '; else if(p==2) for(int i=1;i<s+1;i++) str[i][0]=' '; else if(p==3) for(int i=1;i<s+1;i++) str[i][s+1]=' '; else if(p==4) for(int j=0;j<s+2;j++) str[s+1][j]=' '; else if(p==5) for(int i=s+2;i<2*s+2;i++) str[i][0]=' '; else if(p==6) for(int i=s+2;i<2*s+2;i++) str[i][s+1]=' '; else if(p==7) for(int j=0;j<s+2;j++) str[2*s+2][j]=' '; } void copy(){ for(int i=0;i<2*s+3;i++){ for(int j=0;j<s+2;j++) str[i][j]=eight[i][j]; } } void print(int x){ copy(); if(x==1){ clear(1); clear(2); clear(4); clear(5); clear(7); } else if(x==2){ clear(2); clear(6); } else if(x==3){ clear(2); clear(5); } else if(x==4){ clear(1); clear(5); clear(7); } else if(x==5){ clear(3); clear(5); } else if(x==6){ clear(3); } else if(x==7){ clear(2); clear(4); clear(5); clear(7); } else if(x==9){ clear(5); } else if(x==0){ clear(4); } } int main() { //freopen("cin.txt","r",stdin); while(cin>>s>>n){ if(s==0&&n[0]=='0') break; createight(); int length=strlen(n); int i,j,k; for(i=0;i<2*s+3;i++){ for(k=0;k<length;k++){ print(n[k]-'0'); for(j=0;j<s+2;j++) printf("%c",str[i][j]); printf(" "); } puts(""); } puts(""); } return 0; }