#define N 1
int main(void)
{
register int i=1;
long int sum=0,j=1;
do{
j*=i++;
sum+=j;
}while(i<=N);
printf("%d\n",sum);
return 0;
}只要不超出范围就可以.
----------------解决方案--------------------------------------------------------
可以用第归啊
----------------解决方案--------------------------------------------------------
#include<stdio.h>
#define N 3
long int sum=0,j=1;
void number(int i)
{
j*=i++;
sum+=j;
if(i>N)
printf("%d\n",sum);
else
number(i);
}
int main(void)
{
number(1);
return 0;
}
----------------解决方案--------------------------------------------------------
谢谢各位了....
----------------解决方案--------------------------------------------------------
#include <iostream>
using namespace std;
int fun(int );
main()
{
int n;
scanf("%d",&n);
printf("%d",fun(n));
system("PAUSE");
}
int fun(int i )
{int j,sum=1,k=1,all=0;
for (j=1;j<=i;j++)
{for (;k<=j;k++)
sum=sum*k;
all+=sum;}
return all;
}
----------------解决方案--------------------------------------------------------