Xuywuk1221 @ 2024-07-31 20:42:23
为什么提交之后全是RE啊, 请大佬帮忙看一下
str=input()
istr=x.split(" ")
for i in range(len(istr)):
istr[i]=int(istr[i])
N=istr[0]
t = 0
zoo=0;
for i in range(N):
for j in range(N):
if(istr[t+1]==0):
t+=1
zoo=1 if zoo==0 else 0
print(t)
print(zoo,end="")
istr[t+1]-=1
print()
by guoyanwei120223 @ 2024-08-20 15:24:17
@Xuywuk1221 请问一下最后一行print是干什么的
by guoyanwei120223 @ 2024-08-20 15:26:27
@Xuywuk1221 if zoo==0 else 0 应该是语法错误
by guoyanwei120223 @ 2024-08-20 15:27:35
@Xuywuk1221 说实话,这个代码可读性很差,看不太懂
by guoyanwei120223 @ 2024-08-20 15:29:17
@Xuywuk1221
我现在学C++,python有点生疏了
一下为C++代码
#include<bits/stdc++.h>
using namespace std;
const int N=205;
int a[N][N]={0},n,x;
int main(){
scanf("%d",&n);
int i=1,ans=1,k=1;
while(cin>>x){
if(i%2==0){
for(int j=1;j<=x;++j){
if(ans>n)ans=1,k++;
a[k][ans]=1;
ans++;
}
}else{
ans+=x;
if(ans>n){
k+=ans/n;
ans%=n;
}
}
i++;
}
for(int l=1;l<=n;++l){
for(int r=1;r<=n;++r){
cout<<a[l][r];
}
cout<<"\n";
}
return 0;
}
by M_C_Yyyds @ 2024-08-28 20:41:10
@ Xuywuk1221,这个istr数组里面的元素好像都没有0
by M_C_Yyyds @ 2024-08-28 20:43:09
我是看得懂的
by M_C_Yyyds @ 2024-08-28 20:44:39
@guoyanwei120223 ,是用来换行的
by M_C_Yyyds @ 2024-08-28 20:46:04
最后一行
by Jack1024 @ 2024-09-01 14:29:49
额
你第二行的x是啥?
by Jack1024 @ 2024-09-01 14:30:44
代码你放到idle里运行一下啊,一堆报错~