收起
计算结果超出long long的数值范围了
long long sum=1改成 unsigned long long sum=1;
printf("%lld",sum)改成printf("%llu",sum);
#include <stdio.h>
int main()
{
unsigned long long sum=1;
long long i=1;
int n;
printf("请输入n的值:");
scanf("%d",&n);
while(i<=n)
{
sum *=i;
i++;
}
printf("%llu",sum);
return 0;
}
报告相同问题?