为什么程序运行后得到数字不对
#include<stdio.h>
int main()
{
int amount;
int n = 1;
scanf("%d",&amount);
while( n <= amount){
amount *= n;
n ++;
}
printf("阶乘为%d",amount);
return 0;
//在D++上运行成功,但是除输入零外的任何数字都无法算出正确的阶乘,一直都是负号开头的数字?
#include<stdio.h>
int main()
{
int amount;
int n = 1;
scanf("%d",&amount);
while( n <= amount){
amount *= n;
n ++;
}
printf("阶乘为%d",amount);
return 0;
//在D++上运行成功,但是除输入零外的任何数字都无法算出正确的阶乘,一直都是负号开头的数字?
2020-03-06
举报