gpt4 book ai didi

C 编程 做 while

转载 作者:太空宇宙 更新时间:2023-11-04 07:31:59 28 4
gpt4 key购买 nike

我刚刚写了这个,但我找不到问题。我使用代码块并编写了这个问题

error: expected 'while' before '{' token
=== Build finished: 1 errors, 1 warnings)

但是我不能在那里写,因为它不正确。有人能帮助我吗?对不起我的工程师。

printf("Put numbers for some reason\n");

int cislo;
int s0,s1,s2,s3,s4,s5,s6,s7,s8,s9;

while(scanf("%d",&cislo)==1){
if (cislo<0)
printf ("Cislo %d, je zaporne, takove neberu", cislo);
}

s0=s1=s2=s3=s4=s5=s6=s7=s8=s9=0;


do (cislo/10);
{
switch (cislo%10);

case 0; ++s0; break;
case 1; ++s1; break;
case 2; ++s2; break;
case 3; ++s3; break;
case 4; ++s4; break;
case 5; ++s5; break;
case 6; ++s6; break;
case 7; ++s7; break;
case 8; ++s8; break;
case 9; ++s9; break;
}

while (cislo>0);

printf("0 %d x \n 1 %d x \n 2 %d x \n 3 %d x \n 4 %d x \n 5 %d x \n 6 %d x \n 7 %d x \n 8 %d x \n 9 %d x \n",s0,s1,s2,s3,s4,s5,s6,s7,s8,s9);

return 0;
}

在最后它必须打印这样的东西:

100
Number: 100 include this numbers :
0 ... 2x
1 ... 1x
2 ... 0x
3 ... 0x
4 ... 0x
5 ... 0x
6 ... 0x
7 ... 0x
8 ... 0x
9 ... 0x

最佳答案

do 
{
cislo /= 10;
switch (cislo%10);

case 0; ++s0; break;
case 1; ++s1; break;
case 2; ++s2; break;
case 3; ++s3; break;
case 4; ++s4; break;
case 5; ++s5; break;
case 6; ++s6; break;
case 7; ++s7; break;
case 8; ++s8; break;
case 9; ++s9; break;
}

while (cislo>0);

试试这个?

关于C 编程 做 while,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12980265/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com