|
行15) : error C2106: '=' : left operand must be l-value 行17) : error C2106: '=' : left operand must be l-value #include <stdio.H> int facs(int n); void main() { int N; printf("请输入N:"); scanf("d%",N); cout<<facs(N); cout<<endl; } int facs(int n) { facs(0)=1;出错行********************************* for(int i=1;i<=n;i++) facs(i)=i*facs(i-1);出错行********************************* return facs(n); } |
|
|
|
足足有一箩筐错误。一定要仔细,先把书看懂再动手编,否则信心打击很大。
由于阶乘增长很快,这里就先不管溢出了。 #include <cstdio> #include <iostream> using namespace std; // 以上为第一处 long facs(int n); int main() { int N; printf( "请输入N: "); scanf( "%d", &N); // 第二处 cout << facs( N ) << endl; return 0; } long facs(int n) // 函数整个帮你重写 { if (n == 1) return 1; else return n * facs( n - 1 ); } |
|
|
UP.楼上高手。
|
|
|
using namespace std;
只有打开名字空间,才能使用cout之类的关键字。 请多多指教。 |
|