我正在尝试运行这个简单的代码:
#include <stdio.h>
int main()
{
int n = 3;
printf("Enter your number: ");
scanf("%d",&n);
int faculty(int n){
int i = 1;
int res = 1;
for (i = 2;i<= n;i++){
res = res * i;
}
printf("the value is %d\n",res);
return(0);
}
}
但不知怎的,没有显示任何结果。您能解释一下应该如何正确实现吗? 提前致谢!
最佳答案
请尝试这个:
#include
int faculty( int n )
{
int i = 1;
int res = 1;
for ( i = 2; i <= n; i++ )
{
res = res * i;
}
printf( "the value is %d\n", res );
getchar( );
return ( 0 );
}
int main( )
{
int n = 3;
printf( "Enter your number: " );
scanf( " %d", &n );
faculty( n );
}
关于c - 简单的 C 程序未打印,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33301386/