求大虾指点!我哪里错了?
题目:编写程序: 从键盘输入n,计算1!+2!+3!+4!+……+n!#include <iostream.h>int main()
{
int n,b,sum;
b=1;
sum=0;
cout<<"n的阶乘是:";
cin>>n;
for(n=1; ;n++)
{
n=b*n;
sum=sum+n;
break;
}
cout<<sum<<endl;
system("pause");
}
#include"iostream.h"#include"windows.h"void main(){ int A(int n);//递归求阶乘 cout<<"请输入N值:"; int i,N,sum=0; cin>>N; if(N>0) { for(i=N;i>=1;i--) { sum+=A(i); } cout<<"结果:"<<sum<<endl; } else cout<<"N必须为正整数!\n"; system("pause");}int A(int n){ if(n>1) return A(n-1)*n; if(n==1) return 1;}