```cpp
#include<iostream>
#include<string>
#include<cstring>
#include<cstdio>
#include<fstream>
using namespace std;
int k;
int p;
ofstream fruit;
void num1(int a)
{
if(a==1)
{
fruit<<" ";
cout<<" ";
}
if(1<a&&a<=k+1)
{
fruit<<"|";
cout<<"|";
}
if(a==k+2)
{
fruit<<" ";
cout<<" ";
}
if(k+2<a&&a<=2*k+2)
{
fruit<<"|";
cout<<"|";
}
if(a==2*k+3)
{
fruit<<" ";
cout<<" ";
}
}
void num2(int a)
{
int b;
if(a==1)
{
cout<<" ";
fruit<<" ";
for(b=1;b<=k;b++)
{
fruit<<"-";
cout<<"-";
}
cout<<" ";
fruit<<" ";
}
if(1<a&&a<=k+1)
{
for(b=1;b<=k+1;b++)
{
fruit<<" ";
cout<<" ";
}
fruit<<"|";
cout<<"|";
}
if(a==k+2)
{
cout<<" ";
fruit<<" ";
for(b=1;b<=k;b++)
{
fruit<<"-";
cout<<"-";
}
fruit<<" ";
cout<<" ";
}
if(k+2<a&&a<=2*k+2)
{
cout<<"|";
fruit<<"|";
for(b=1;b<=k+1;b++)
{
fruit<<" ";
cout<<" ";
}
}
if(a==2*k+3)
{
cout<<" ";
fruit<<" ";
for(b=1;b<=k;b++)
{
fruit<<"-";
cout<<"-";
}
fruit<<" ";
cout<<" ";
}
}
void num3(int a)
{
int b;
if(a==1)
{
cout<<" ";
fruit<<" ";
for(b=1;b<=k;b++)
{
fruit<<"-";
cout<<"-";
}
fruit<<" ";
cout<<" ";
}
if(1<a&&a<=k+1)
{
for(b=1;b<=k+1;b++)
{
fruit<<" ";
cout<<" ";
}
fruit<<"|";
cout<<"|";
}
if(a==k+2)
{
cout<<" ";
fruit<<" ";
for(b=1;b<=k;b++)
{
fruit<<"-";
cout<<"-";
}
fruit<<" ";
cout<<" ";
}
if(k+2<a&&a<=2*k+2)
{
for(b=1;b<=k+1;b++)
{
fruit<<" ";
cout<<" ";
}
fruit<<"|";
cout<<"|";
}
if(a==2*k+3)
{
cout<<" ";
fruit<<" ";
for(b=1;b<=k;b++)
{
fruit<<"-";
cout<<"-";
}
fruit<<" ";
cout<<" ";
}
}
void num4(int a)
{
int b;
if(a==1)
{
for(b=1;b<=k+2;b++)
{
fruit<<" ";
cout<<" ";
}
}
if(1<a&&a<=k+1)
{
cout<<"|";
fruit<<"|";
for(b=1;b<=k;b++)
{
fruit<<" ";
cout<<" ";
}
fruit<<"|";
cout<<"|";
}
if(a==k+2)
{
cout<<" ";
fruit<<" ";
for(b=1;b<=k;b++)
{
fruit<<"-";
cout<<"-";
}
fruit<<" ";
cout<<" ";
}
if(k+2<a&&a<=2*k+2)
{
for(b=1;b<=k+1;b++)
{
fruit<<" ";
cout<<" ";
}
fruit<<"|";
cout<<"|";
}
if(a==2*k+3)
{
for(b=1;b<=k+2;b++)
{
fruit<<" ";
cout<<" ";
}
}
}
void num5(int a)
{
int b;
if(a==1)
{
cout<<" ";
fruit<<" ";
for(b=1;b<=k;b++)
{
fruit<<"-";
cout<<"-";
}
fruit<<" ";
cout<<" ";
}
if(1<a&&a<=k+1)
{
cout<<"|";
fruit<<"|";
for(b=1;b<=k+1;b++)
{
fruit<<" ";
cout<<" ";
}
}
if(a==k+2)
{
cout<<" ";
fruit<<" ";
for(b=1;b<=k;b++)
{
fruit<<"-";
cout<<"-";
}
fruit<<" ";
cout<<" ";
}
if(k+2<a&&a<=2*k+2)
{
for(b=1;b<=k+1;b++)
{
fruit<<" ";
cout<<" ";
}
fruit<<"|";
cout<<"|";
}
if(a==2*k+3)
{
cout<<" ";
fruit<<" ";
for(b=1;b<=k;b++)
{
fruit<<"-";
cout<<"-";
}
fruit<<" ";
cout<<" ";
}
}
void num6(int a)
{
int b;
if(a==1)
{
cout<<" ";
fruit<<" ";
for(b=1;b<=k;b++)
{
fruit<<"-";
cout<<"-";
}
fruit<<" ";
cout<<" ";
}
if(1<a&&a<=k+1)
{
cout<<"|";
fruit<<"|";
for(b=1;b<=k+1;b++)
{
fruit<<" ";
cout<<" ";
}
}
if(a==k+2)
{
cout<<" ";
fruit<<" ";
for(b=1;b<=k;b++)
{
fruit<<"-";
cout<<"-";
}
fruit<<" ";
cout<<" ";
}
if(k+2<a&&a<=2*k+2)
{
cout<<"|";
fruit<<"|";
for(b=1;b<=k;b++)
{
fruit<<" ";
cout<<" ";
}
fruit<<"|";
cout<<"|";
}
if(a==2*k+3)
{
fruit<<" ";
cout<<" ";
for(b=1;b<=k;b++)
{
fruit<<"-";
cout<<"-";
}
fruit<<" ";
cout<<" ";
}
}
void num7(int a)
{
int b;
if(a==1)
{
cout<<" ";
fruit<<" ";
for(b=1;b<=k;b++)
{
fruit<<"-";
cout<<"-";
}
fruit<<" ";
cout<<" ";
}
if(1<a&&a<=k+1)
{
for(b=1;b<=k+1;b++)
{
fruit<<" ";
cout<<" ";
}
fruit<<"|";
cout<<"|";
}
if(a==k+2)
{
for(b=1;b<=k+2;b++)
{
fruit<<" ";
cout<<" ";
}
}
if(k+2<a&&a<=2*k+2)
{
for(b=1;b<=k+1;b++)
{
fruit<<" ";
cout<<" ";
}
fruit<<"|";
cout<<"|";
}
if(a==2*k+3)
{
for(b=1;b<=k+2;b++)
{
fruit<<" ";
cout<<" ";
}
}
}
void num8(int a)
{
int b;
if(a==1)
{
cout<<" ";
fruit<<" ";
for(b=1;b<=k;b++)
{
fruit<<"-";
cout<<"-";
}
fruit<<" ";
cout<<" ";
}
if(1<a&&a<=k+1)
{
cout<<"|";
fruit<<"|";
for(b=1;b<=k;b++)
{
fruit<<" ";
cout<<" ";
}
fruit<<"|";
cout<<"|";
}
if(a==k+2)
{
cout<<" ";
fruit<<" ";
for(b=1;b<=k;b++)
{
fruit<<"-";
cout<<"-";
}
fruit<<" ";
cout<<" ";
}
if(k+2<a&&a<=2*k+2)
{
cout<<"|";
fruit<<"|";
for(b=1;b<=k;b++)
{
fruit<<" ";
cout<<" ";
}
fruit<<"|";
cout<<"|";
}
if(a==2*k+3)
{
cout<<" ";
fruit<<" ";
for(b=1;b<=k;b++)
{
fruit<<"-";
cout<<"-";
}
fruit<<" ";
cout<<" ";
}
}
void num9(int a)
{
int b;
if(a==1)
{
cout<<" ";
fruit<<" ";
for(b=1;b<=k;b++)
{
fruit<<"-";
cout<<"-";
}
fruit<<" ";
cout<<" ";
}
if(1<a&&a<=k+1)
{
cout<<"|";
fruit<<"|";
for(b=1;b<=k;b++)
{
fruit<<" ";
cout<<" ";
}
fruit<<"|";
cout<<"|";
}
if(a==k+2)
{
cout<<" ";
fruit<<" ";
for(b=1;b<=k;b++)
{
fruit<<"-";
cout<<"-";
}
fruit<<" ";
cout<<" ";
}
if(k+2<a&&a<=2*k+2)
{
for(b=1;b<=k+1;b++)
{
fruit<<" ";
cout<<" ";
}
fruit<<"|";
cout<<"|";
}
if(a==2*k+3)
{
cout<<" ";
fruit<<" ";
for(b=1;b<=k;b++)
{
fruit<<"-";
cout<<"-";
}
fruit<<" ";
cout<<" ";
}
}
void num0(int a)
{
int b;
if(a==1)
{
cout<<" ";
fruit<<" ";
for(b=1;b<=k;b++)
{
fruit<<"-";
cout<<"-";
}
fruit<<" ";
cout<<" ";
}
if(1<a&&a<=k+1)
{
cout<<"|";
fruit<<"|";
for(b=1;b<=k;b++)
{
fruit<<" ";
cout<<" ";
}
fruit<<"|";
cout<<"|";
}
if(a==k+2)
{
for(b=1;b<=k+2;b++)
{
fruit<<" ";
cout<<" ";
}
}
if(k+2<a&&a<=2*k+2)
{
cout<<"|";
fruit<<"|";
for(b=1;b<=k;b++)
{
fruit<<" ";
cout<<" ";
}
fruit<<"|";
cout<<"|";
}
if(a==2*k+3)
{
cout<<" ";
fruit<<" ";
for(b=1;b<=k;b++)
{
fruit<<"-";
cout<<"-";
}
cout<<" ";
fruit<<" ";
}
}
int main()
{
fruit.open("test.txt");
int a,b,c,d;
string m;
cin>>k;
cin>>m;
b=2*k+3;
d=m.size();
for(a=1;a<=b;a++)
{
for(c=0;c<d;c++)
{
if(m[c]==49) num1(a);
if(m[c]==50) num2(a);
if(m[c]==51) num3(a);
if(m[c]==52) num4(a);
if(m[c]==53) num5(a);
if(m[c]==54) num6(a);
if(m[c]==55) num7(a);
if(m[c]==56) num8(a);
if(m[c]==57) num9(a);
if(m[c]==48) num0(a);
if(c!=d-1)
{
fruit<<" ";
cout<<" ";
}
}
fruit<<endl;
cout<<endl;
}
return 0;
}
```
by DGunner @ 2019-02-14 22:15:27
#Up
by DGunner @ 2019-02-14 22:41:58
#### 你知不知道这世界上有一个叫switch的分支结构。。。
###### (我一直以为我的代码是差不多最多的,直到我看到一个比我多3倍的代码(yours))
##### 我的代码(仅供参考,没有AC,因为我看不懂luogu给出的那一堆乱七八糟的数据点,我觉得我的输出比它好看多了-_-)
```
#include<bits/stdc++.h>
using namespace std;
void count(char a[],int n)
{
cout<<" ";
for(int i=0;a[i]!='\0';i++)
{
switch (a[i])
{
case '1':
{
cout<<" ";
break;
}
case '2':
case '3':
case '5':
case '6':
case '7':
case '8':
case '9':
case '0':
{
cout<<" ";
for(int j=0;j<n;j++) cout<<"-";
cout<<" ";
break;
}
case '4':
{
cout<<" ";
for(int j=0;j<n;j++) cout<<" ";
cout<<" ";
break;
}
}
}
cout<<endl;
for(int j=0;j<n;j++)
{
cout<<" ";
for(int i=0;a[i]!='\0';i++)
{
switch (a[i])
{
case '1':
{
cout<<"| ";
break;
}
case '5':
case '6':
{
cout<<"|";
for(int k=0;k<n;k++) cout<<" ";
cout<<" ";
break;
}
case '2':
case '3':
case '7':
{
cout<<" ";
for(int k=0;k<n;k++) cout<<" ";
cout<<"| ";
break;
}
case '4':
case '8':
case '9':
case '0':
{
cout<<"|";
for(int k=0;k<n;k++) cout<<" ";
cout<<"| ";
break;
}
}
}
cout<<endl;
}
cout<<" ";
for(int i=0;a[i]!='\0';i++)
{
switch (a[i])
{
case '1':
{
cout<<" ";
break;
}
case '2':
case '3':
case '4':
case '5':
case '6':
case '8':
case '9':
{
cout<<" ";
for(int j=0;j<n;j++) cout<<"-";
cout<<" ";
break;
}
case '0':
case '7':
{
cout<<" ";
for(int j=0;j<n;j++) cout<<" ";
cout<<" ";
break;
}
}
}
cout<<endl;
for(int j=0;j<n;j++)
{
cout<<" ";
for(int i=0;a[i]!='\0';i++)
{
switch (a[i])
{
case '1':
{
cout<<"| ";
break;
}
case '2':
{
cout<<"|";
for(int k=0;k<n;k++) cout<<" ";
cout<<" ";
break;
}
case '3':
case '4':
case '5':
case '7':
case '9':
{
cout<<" ";
for(int k=0;k<n;k++) cout<<" ";
cout<<"| ";
break;
}
case '6':
case '8':
case '0':
{
cout<<"|";
for(int k=0;k<n;k++) cout<<" ";
cout<<"| ";
break;
}
}
}
cout<<endl;
}
cout<<" ";
for(int i=0;a[i]!='\0';i++)
{
switch (a[i])
{
case '1':
{
cout<<" ";
break;
}
case '2':
case '3':
case '5':
case '6':
case '8':
case '9':
case '0':
{
cout<<" ";
for(int j=0;j<n;j++) cout<<"-";
cout<<" ";
break;
}
case '4':
case '7':
{
cout<<" ";
for(int j=0;j<n;j++) cout<<" ";
cout<<" ";
break;
}
}
}
}
int main()
{
int k;
cin>>k;
char a[226];
cin>>a;
count(a,k);
}
```
不过我也是暴力解决的,这题好像没什么规律吧...
by BanKim @ 2019-05-24 21:20:15
#### 嗯,这样我们光加起来的代码就有800多行了,有没有人翻到这里都是问题,所以还是乖乖去题解吧
by BanKim @ 2019-05-24 21:23:23
有没有人翻到这里都是问题?我翻过来了
by D447H @ 2019-08-15 13:53:49
我也翻过来了
by chenxuanting @ 2019-08-20 14:31:12
能否打表
by wangzicheng2009 @ 2022-07-09 11:30:47