Lilindong @ 2024-08-02 16:51:31
#include<stdio.h>
int main()
{
int n,i,j;
char a[101];
char* b[10][5]={"XXX",
"X.X",
"X.X",
"X.X",
"XXX",
"..X",
"..X",
"..X",
"..X",
"..X",
"XXX",
"..X",
"XXX",
"X..",
"XXX",
"XXX",
"..X",
"XXX",
"..X",
"XXX",
"X.X",
"X.X",
"XXX",
"..X",
"..X",
"XXX",
"X..",
"XXX",
"..X",
"XXX",
"XXX",
"X..",
"XXX",
"X.X",
"XXX",
"XXX",
"..X",
"..X",
"..X",
"..X",
"XXX",
"X.X",
"XXX",
"X.X",
"XXX",
"XXX",
"X.X",
"XXX",
"..X",
"XXX"};
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%c",&a[i]);
for(i=0;i<5;i++)
{
for(j=0;j<n;j++)
{
printf("%s",b[a[j]-'0'][i]);
if(j!=n-1)
printf(".");
}
printf("\n");
}
return 0;
}
by hyl_____ @ 2024-08-02 16:55:25
字符数组的每一项只能装一个字符,你这个肯定废
by qazsedcrfvgyhnujijn @ 2024-08-02 17:03:38
@hyl_____ 有没有一种可能,他写的是 char *[][]
,等价于 char [][][]
by hyl_____ @ 2024-08-02 17:13:25
但是这样的话他下面使用数组时会导致错误
by hyl_____ @ 2024-08-02 17:13:32
(⊙o⊙)…
by lengfengwcx @ 2024-08-03 17:50:15
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,i,j,c=0,m;
cin>>n;
string s,ans[15];
cin>>s;
for(i=0;i<s.size();i++)
{
if(s[i]=='0')
{
ans[0]+="XXX";
ans[4]+="XXX";
ans[1]+="X.X";
ans[2]+="X.X";
ans[3]+="X.X";
}
if(s[i]=='1')
{
ans[0]+="..X";
ans[4]+="..X";
ans[1]+="..X";
ans[2]+="..X";
ans[3]+="..X";
}
if(s[i]=='2')
{
ans[0]+="XXX";
ans[4]+="XXX";
ans[1]+="..X";
ans[2]+="XXX";
ans[3]+="X..";
}
if(s[i]=='3')
{
ans[0]+="XXX";
ans[4]+="XXX";
ans[1]+="..X";
ans[2]+="XXX";
ans[3]+="..X";
}
if(s[i]=='4')
{
ans[0]+="X.X";
ans[4]+="..X";
ans[1]+="X.X";
ans[2]+="XXX";
ans[3]+="..X";
}
if(s[i]=='5')
{
ans[0]+="XXX";
ans[4]+="XXX";
ans[1]+="X..";
ans[2]+="XXX";
ans[3]+="..X";
}
if(s[i]=='6')
{
ans[0]+="XXX";
ans[4]+="XXX";
ans[1]+="X..";
ans[2]+="XXX";
ans[3]+="X.X";
}
if(s[i]=='7')
{
ans[0]+="XXX";
ans[4]+="..X";
ans[1]+="..X";
ans[2]+="..X";
ans[3]+="..X";
}
if(s[i]=='8')
{
ans[0]+="XXX";
ans[4]+="XXX";
ans[1]+="X.X";
ans[2]+="XXX";
ans[3]+="X.X";
}
if(s[i]=='9')
{
ans[0]+="XXX";
ans[4]+="XXX";
ans[1]+="X.X";
ans[2]+="XXX";
ans[3]+="..X";
}
if(i!=s.size()-1)
{
ans[0]+=".";
ans[4]+=".";
ans[1]+=".";
ans[2]+=".";
ans[3]+=".";
}
}
cout<<ans[0]<<endl<<ans[1]<<endl<<ans[2]<<endl<<ans[3]<<endl<<ans[4]<<endl;//五行逐一输出
return 0;
}
应该这样吧 我过了