我使用Visual Studio收到以下错误:
41智能感知:预期标识符
我不知道这是想说什么,任何帮助将不胜感激! :d
以下是该计划:
#include <stdio.h>
#include <math.h>
int
main(void)
{
long long d;
long long p;
//Ask for numbers of days as long as input is not between 28 and 31
do
{
printf("How may days are in your month?\n");
d = GetInt();
}
while (d<28 || d>31);
//Ask for numbers of pennies for day 1 as long as input is negative
printf("How many pennies do you have");
do
{
p = GetInt();
}
while ("p<0");
//Sum up the pennies, pennies = (pennies*2)*2..*2
int 1;
for (i=0; i<= d-1; i++);
{
p=p*pow(2,i);
}
printf("%lld\n", p);
return 0;
}`
答案 0 :(得分:5)
int 1;
for (i=0; i<= d-1; i++);
这里有int 1;
,因此编译器正在寻找变量名称,例如int x = 1;
现在是for循环,从末尾删除;
在main
的前两行内
long long d;
long long p;
此处long
是一种类型,因此请将这些行更改为
long d;
long p;
在您的文件末尾,我看到}'
,此处删除'
字符
此外,我可以看到您有while ("p<0");
作为while条件,此处"p<0"
是一个字符串,您可能希望将其更改为p<0
。
答案 1 :(得分:2)
您可能还想替换
while ("p<0");
带
while(p<0);
(不含引号)。