【发布时间】:2020-06-24 07:42:54
【问题描述】:
为什么会出现语法错误,我认为没有任何问题。谢谢.. 语法错误在第 2 行。
#include <stdio.h>
int main() {
long int sum;
int an;
printf("Sum of multiples of three and five\nEnter the nth value\n>> ");
scanf("%d",&an);
sum=((3/2*an/3*(an/3+1))+(5/2*an/5*(an/5+1))-(15/2*an/15*(an/15+1)));
printf("The sum of multiples of 3 and 5 under %d is %ld",an,sum);
}
【问题讨论】:
-
sum=(3/2*an/3*(an/3+1))+(5/2*an/5*(an/5+1))-(15/2*an/15*(an/15+1))..missing; -
欢迎来到 Stack Overflow! 这个问题是由无法再重现的问题或简单的印刷错误引起的。虽然类似的问题可能是这里的主题,但这个问题的解决方式不太可能帮助未来的读者。这通常可以通过在发布前识别并仔细检查the shortest program necessary to reproduce the problem 来避免。
-
然后向我们展示您拥有的代码,而不是您认为拥有的代码。
-
当然不真实。您编辑添加了
;,现在此代码不会重现您之前所说的问题。 -
请test那个公式。您知道整数除法(
3/2、an/3、15/2...)的行为方式吗?
标签: c sum syntax-error