gpt4 book ai didi

c - 输入末尾的预期声明或语句?

转载 作者:行者123 更新时间:2023-11-30 21:38:06 25 4
gpt4 key购买 nike

我很无聊......并决定进行此编码,尚未完成,但我想知道为什么它还无法编译。

/*Coding that will countdown the amount of bottles on the wall
*/
#include<stdio.h>
int main()
{
int bottles = 99;
while (bottles >= 0) {
put ("%i\n bottles of beer on the wall, %i\n bottles of beer, take one down pass it around", bottles, bottles) ; {
bottles--;
put ("%i\n bottles of beer on the wall", bottles) ;
}
continue; }

最佳答案

我不同意你的大括号太少的答案:你也可能有一个(在 put() 的最后...将其更改为

/*Coding that will countdown the amount of bottles on the wall
*/
#include<stdio.h>
int main()
{
int bottles = 99;
while (bottles > 0) // got rid of '='... Since decrementing inside loop
{
printf ("%i bottles of beer on the wall, %i bottles of beer\n", bottles, bottles);
printf("Take one down pass it around\n"); // <<<<removed a '}' here...>>>>
bottles--;
printf("%i bottles of beer on the wall\n\n", bottles) ;
}
continue; // what is this doing here??? You are not in a while loop...
}

注意 - 我将一个 put 拆分为两个 printf 语句,并更改了 '\n' 的放置位置。

关于c - 输入末尾的预期声明或语句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19992810/

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