Elizabeththh @ 2024-11-03 10:23:12
#include <stdio.h>
int main()
{
int n = 0;
scanf("%d",&n);
int zip[40000] = {0};
for(int i = 0;getchar() != '\n';i++)
{
scanf("%d",&zip[i]);
}
int sum = 0;
int i = 0,width = 0;
while(sum != n*n)
{
if(i % 2 == 0)
{
for(int j = 0;j < zip[i];j++)
{
if(width < 7)
{
printf("0");
width++;
}
else
{
printf("\n0");
width = 1;
}
}
sum+=zip[i];
i++;
}
else
{
for(int j = 0;j < zip[i];j++)
{
if(width < 7)
{
printf("1");
width++;
}
else
{
printf("\n1");
width = 1;
}
}
sum+=zip[i];
i++;
}
}
}
by Husig @ 2024-11-03 10:31:23
题?
by go_your_a_head @ 2024-11-03 10:34:24
@Elizabeththh 读入都有问题
by go_your_a_head @ 2024-11-03 10:36:49
@Elizabeththh 读入没有这么复杂,知道n了之后,就可以知道有多少个0和1,如n=7,则0和1共有49个,一边读入一边累加即可
by go_your_a_head @ 2024-11-03 10:37:50
@Elizabeththh 你先把读入改一下,还有问题你可以再发帖
by Elizabeththh @ 2024-11-03 10:51:25
@hujiasheng0102 题目是P1319
by go_your_a_head @ 2024-11-03 10:54:33
@Elizabeththh 读入改完了吗?你说一下你的思路,我帮你看一看主体部分写没写错
by Elizabeththh @ 2024-11-03 10:55:03
@Licak 这个读入我在vscode上运行的样例是对的,是因为评测机输入样例结束时没有换行符吗
by go_your_a_head @ 2024-11-03 10:58:22
@Elizabeththh 可以当我没说,我看成有换行符了
by go_your_a_head @ 2024-11-03 11:02:34
@Elizabeththh 思路?
by youyew2007 @ 2024-11-03 11:05:32
@Elizabeththh 这种单行的读入是可能没有换行符的,你可以用一个变量来存已经有了多少个数,小于