-5

我很无聊......并决定进行这个编码,它还没有完成,但我想知道为什么它还不能编译。

/*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; }
4

2 回答 2

1

我不同意说你有一个太少的括号的答案:你也有一个可能(在最后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'放置的位置。

于 2013-11-15T03:24:27.507 回答
0

通常,当您遗漏括号时会出现此错误。您缺少一个右括号}

#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; 
}
}
于 2013-11-15T03:17:02.727 回答