#include <iostream>
using namespace std;
int factor(int n);
int main()
{
int f,n;
// Get user input
cout << "Enter an integer: ";
cin >> n;
// Call factorial function
f = factor(n);
// Output results
cout << n << "! = " << f << endl;
int factor (int n)
if(n <=1)
{
return 1;
}
else
{
int c = n * (n-1);
return c;
}
};
我收到错误 C2143:语法错误:缺少 ';' 在“如果”之前,我很好奇我是否遗漏了一些简单的东西。我对 C++ 相当陌生。