canadian_people @ 2023-03-09 20:27:36
#include <bits/stdc++.h>
using namespace std;
int n,i,j,x,y,s,t;
int f[10][8]={
{6,0,1,2,4,5,6},{2,2,5},{5,0,2,3,4,6},{5,0,2,3,5,6},
{4,1,2,3,5},{5,0,1,3,5,6},{6,0,1,3,4,5,6},{3,0,2,5},
{7,0,1,2,3,4,5,6},{6,0,1,2,3,5,6}
};
int d[7][3][2]={
{{0,0},{0,1},{0,2}},
{{0,0},{1,0},{2,0}},
{{0,2},{1,2},{2,2}},
{{2,0},{2,1},{2,2}},
{{2,0},{3,0},{4,0}},
{{2,2},{3,2},{4,2}},
{{4,0},{4,1},{4,2}}
};
char a[101],c[5][500];
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>n>>a+1;
for(i=1;i<=5;i++)
for(j=1;j<=4*n-1;j++) c[i][j]='.';
for(i=1;i<=n;i++){
x=0;y=i*4;s=a[i]-'0';
for(j=1;j<=f[s][0];j++){
t=f[s][j];
c[x+s[t][0][0]][y+d[t][0][1]]='X';
c[x+s[t][1][0]][y+d[t][1][1]]='X';
c[x+s[t][2][0]][y+d[t][2][1]]='X';
}
}
for(i=1;i<=5;i++,cout<<"\n")
for(j=1;j<=4*n-1;j++) cout<<c[i][j];
}
编译错误,
报错:
[Error] invalid types 'int[int]' for array subscript
by __Tao__ @ 2023-03-09 20:34:50
c[x+s[t][0][0]][y+d[t][0][1]]='X';
c[x+s[t][1][0]][y+d[t][1][1]]='X';
c[x+s[t][2][0]][y+d[t][2][1]]='X';
s是一个变量,你却用下标访问
by hjsxhst2022 @ 2023-03-09 20:36:43
@canadian_people 变量s不是数组,不可以用下标
by canadian_people @ 2023-03-09 20:38:20
@hjsxhst2022 我成朵拉了