Wrong Answer
代码
#include <stdio.h>
int factorial(int n);
int main(int argc, char const *argv[])
{
int n;
scanf("%d", &n);
if (n>0)
{
printf("%d\n", factorial(n));
}
else
{
printf("请重新输入一个非负整数:");
scanf("%d", &n);
printf("%d\n", factorial(n));
}
return 0;
}
int factorial(int n)
{
int fact = 1;
for (int i = 1; i <= n; ++i)
{
fact = fact*i;
}
return fact;
}