fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define FR0(i,N) for(i=0;i<(N);i++)
  4. #define FR1(i,N) for(i=1;i<=(N);i++)
  5. #define FRN(i,k,N) for(i=k;i<(N);i++)
  6. #define pf printf
  7. #define db double
  8. #define max3(a,b,c) max(max(a,b),c)
  9. #define min3(a,b,c) min(min(a,b),c)
  10. #define sci(n) scanf("%d",&n)
  11. #define scl(n) scanf("%lld",&n)
  12. #define scf(n) scanf("%f",&n)
  13. #define scd(n) scanf("%lf",&n)
  14. #define scs(s) scanf("%s",&s)
  15. #define scll(n) scanf("%%I64d",&n)
  16. #define PI acos(-1.0)
  17. #define LL long long
  18. #define MX 1000005
  19. #define MOD 1000000007
  20. typedef long long int ll;
  21. bool status[1100002];
  22.  
  23. int main()
  24. {
  25. int s;
  26. string n;
  27. int h[10][3];//horizontal line array size .here 9 means it may be 1,2,3,4,5,6,7,8,9 and 3 means here any number to made need maximum 3 horizontal line.
  28.  
  29. h[0][0]=h[0][2]=1;//horizontal line for 0;
  30. h[0][1]=0;
  31.  
  32. h[1][0]=h[1][1]=h[1][2]=0;//horizontal line for 1;
  33.  
  34. h[2][0]=h[2][1]=h[2][2]=1; //horizontal line for 2;
  35.  
  36. h[3][0]=h[3][1]=h[3][2]=1; //horizontal line for 3;
  37.  
  38. h[4][1]=1;
  39. h[4][0]=h[4][2]=0; //horizontal line for 4;
  40.  
  41. h[5][0]=h[5][1]=h[5][2]=1;//horizontal line for 5;
  42.  
  43. h[6][0]=h[6][1]=h[6][2]=1; //horizontal line for 6;
  44.  
  45. h[7][0]=1;//horizontal line for 7;
  46. h[7][1]=h[7][2]=0;
  47.  
  48. h[8][0]=h[8][1]=h[8][2]=1;//horizontal line for 8;
  49.  
  50. h[9][0]=h[9][1]=h[9][2]=1;//horizontal line for 9;
  51.  
  52.  
  53. int v[10][4];//vertical line array size.Here 9 means digit can be 1,2,3,4,5,6,7,8,9 and 3 means vertical line can be maximum 4 for any digit representation;
  54.  
  55. v[0][1]=v[0][3]=v[0][0]=v[0][2]=1;//vertical line for digit 0;
  56.  
  57. v[1][1]=v[1][3]=1;//vertical line for digit 1;
  58. v[1][0]=v[1][2]=0;
  59.  
  60. v[2][1]=v[2][2]=1;//vertical line representation for digit 2;
  61. v[2][0]=v[2][3]=0;
  62.  
  63. v[3][1]=v[3][3]=1;//vertical line representation for digit 3;
  64. v[3][0]=v[3][2]=0;
  65.  
  66. v[4][0]=v[4][1]=v[4][3]=1;//vertical line representation for digit 4;
  67. v[4][2]=0;
  68.  
  69. v[5][0]=v[5][3]=1;//vertical line representation for digit 5;
  70. v[5][1]=v[5][2]=0;
  71.  
  72. v[6][0]=v[6][2]=v[6][3]=1;//vertical line representation for digit 6;
  73. v[6][1]=0;
  74.  
  75. v[7][1]=v[7][3]=1;//vertical line representation for digit 7;
  76. v[7][0]=v[7][2]=0;
  77.  
  78. v[8][0]=v[8][1]=v[8][2]=v[8][3]=1;//vertical line representation for digit 8;
  79.  
  80. v[9][0]=v[9][1]=v[9][3]=1;//vertical line representation for digit 9;
  81. v[9][2]=0;
  82.  
  83.  
  84. while(cin>>s>>n)
  85. {
  86. //cout<<"f"<<endl;
  87. if(s==0) break;
  88. //cout<<"check"<<endl;
  89. for(int i=0; i<n.length(); i++) //Stating first horizontal checking
  90. {
  91. if(i!=0)
  92. {
  93. //cout<<" ";
  94. pf(" ");
  95. }
  96. //cout<<" ";
  97. pf(" ");
  98. // cout<<"pass"<<endl;
  99. if(h[n[i]-'0'][0])
  100. {
  101. for(int j=0; j<s; j++)
  102. {
  103. //cout<<"-";
  104. pf("-");
  105. }
  106. }
  107. else
  108. {
  109. for(int j=0; j<s; j++)
  110. {
  111. //cout<<" ";
  112. pf(" ");
  113. }
  114. }
  115. // cout<<" ";
  116. pf(" ");
  117. }
  118. //cout<<endl;//End of first horizontal checking;
  119. pf("\n");
  120. //cout<<"yes"<<endl;
  121.  
  122.  
  123. for(int j=0; j<s; j++) //Checking start 1st and 2nd vertical line for each digit;
  124. {
  125. for(int i=0; i<n.length(); i++)
  126. {
  127. if(i!=0)
  128. {
  129. // cout<<" ";
  130. pf(" ");
  131. }
  132. if(v[n[i]-'0'][0])
  133. {
  134. //cout<<"|";
  135. pf("|");
  136. }
  137. else
  138. {
  139. ///cout<<" ";
  140. pf(" ");
  141. }
  142. for(int i=0; i<s; i++)
  143. {
  144. //cout<<" ";
  145. pf(" ");
  146. }
  147. if(v[n[i]-'0'][1])
  148. {
  149. //cout<<"|";
  150. pf("|");
  151. }
  152. else
  153. {
  154. //cout<<" ";
  155. pf(" ");
  156. }
  157. }
  158. //cout<<endl;//Checking end 1st and 2nd vertical line for each digit;
  159. pf("\n");
  160. }
  161.  
  162.  
  163.  
  164. for(int i=0; i<n.length(); i++)//Checking start 2nd horizontal for each digit representation;
  165. {
  166. if(i!=0)
  167. {
  168. //cout<<" ";
  169. pf(" ");
  170. }
  171. cout<<" ";
  172. if(h[n[i]-'0'][1])
  173. {
  174. for(int j=0; j<s; j++)
  175. {
  176. //cout<<"-";
  177. pf("-");
  178. }
  179. }
  180. else
  181. {
  182. for(int j=0; j<s; j++)
  183. {
  184. //cout<<" ";
  185. pf(" ");
  186. }
  187. }
  188. //cout<<" ";
  189. pf(" ");
  190. }
  191. //cout<<endl;//Checking start 2nd horizontal for each digit representation;
  192. pf("\n");
  193.  
  194.  
  195. for(int j=0; j<s; j++) //Checking start 3rd and 4th vertical for each digit representation;
  196. {
  197. for(int i=0; i<n.length(); i++)
  198. {
  199. if(i!=0)
  200. {
  201. //cout<<" ";
  202. pf(" ");
  203. }
  204. if(v[n[i]-'0'][2])
  205. {
  206. //cout<<"|";
  207. pf("|");
  208. }
  209. else
  210. {
  211. //cout<<" ";
  212. pf(" ");
  213. }
  214. for(int i=0; i<s; i++)
  215. {
  216. //cout<<" ";
  217. pf(" ");
  218. }
  219. if(v[n[i]-'0'][3])
  220. {
  221. //cout<<"|";
  222. pf("|");
  223. }
  224. else
  225. {
  226. //cout<<" ";
  227. pf(" ");
  228. }
  229. }
  230. //cout<<endl;//Checking end 3rd and 4th vertical for each digit representation;
  231. pf("\n");
  232. }
  233.  
  234.  
  235. for(int i=0; i<n.length(); i++) //Stating 3rd horizontal checking
  236. {
  237. if(i!=0)
  238. {
  239. //cout<<" ";
  240. pf(" ");
  241. }
  242. //cout<<" ";
  243. pf(" ");
  244. if(h[n[i]-'0'][2])
  245. {
  246. for(int j=0; j<s; j++)
  247. {
  248. //cout<<"-";
  249. pf("-");
  250. }
  251. }
  252. else
  253. {
  254. for(int j=0; j<s; j++)
  255. {
  256. //cout<<" ";
  257. pf(" ");
  258. }
  259. }
  260. //cout<<" ";
  261. pf(" ");
  262. }
  263. //cout<<endl<<endl;//end 3rd horizontal checking
  264. pf("\n\n");
  265. }
  266. }
  267.  
Success #stdin #stdout 0s 4492KB
stdin
2 12345
3 67890
0 0
stdout
      --   --        -- 
   |    |    | |  | |   
   |    |    | |  | |   
      --   --   --   -- 
   | |       |    |    |
   | |       |    |    |
      --   --        -- 

 ---   ---   ---   ---   --- 
|         | |   | |   | |   |
|         | |   | |   | |   |
|         | |   | |   | |   |
 ---         ---   ---       
|   |     | |   |     | |   |
|   |     | |   |     | |   |
|   |     | |   |     | |   |
 ---         ---   ---   ---