Max6700 @ 2023-05-03 11:31:35
#include<bits/stdc++.h>
using namespace std;
int n;
char c[100000];
int a[100000];
int main(){
cin>>n;
int i=1;
while(cin>>c[i])
{
a[i]=int(c[i]-'0');
i++;
}
int now1=0;
int now2=1;
while(now2<=i)
{
for(int j=1;j<=a[now2];j++)
{
now1++;
cout<<(now2+1)%2;
if(now1%n==0)cout<<"\n";
}
now2++;
}
return 0;
}
by D0000 @ 2023-05-03 12:01:29
输入的问题 可以以字符串读入
by Max6700 @ 2023-05-03 12:06:44
@cdrdyl 嗯?
by Max6700 @ 2023-05-03 12:07:03
@cdrdyl [不解]
by Max6700 @ 2023-05-03 12:12:06
@cdrdyl 字符串遇到空格会停止读入……
by D0000 @ 2023-05-03 13:35:07
有了,判断输入的数的总和,如果等于n*n,就停止
by Max6700 @ 2023-05-03 21:12:24
@cdrdyl 嗯?听起来好像可刑,我试试
by Max6700 @ 2023-05-03 21:13:57
@cdrdyl 哇!!!过了!thx!!!
by Max6700 @ 2023-05-03 21:17:10
@cdrdyl AC力!
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
int a[100000];
int sum;
int main(){
cin>>n;
int i=1;
while(sum<n*n)
{
cin>>a[i];
sum+=a[i];
i++;
}
int now1=0;
int now2=1;
while(now2<=i)
{
for(int j=1;j<=a[now2];j++)
{
now1++;
cout<<(now2+1)%2;
if(now1%n==0)cout<<"\n";
}
now2++;
}
return 0;
}