我是初学者问个问题,这两个有啥区别?
#include<stdio.h>void main()
{
int i,n,s,a,b;
s=0;a=1;i=1;b=1;
printf("please intput n\n");
scanf("%d",&n);
while(i<=n)
{
i++;
s=s+a;
while(b<=i)
{
a=a*b;
b++;
}
}
printf("所得值为%d\n",s);
}
#include<stdio.h>
void main()
{
int i,n,s,a,b;
s=0;a=1;
printf("please intput n\n");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
s=s+a;
for(b=1;b<=i;b++)
{
a=a*b;
}
}
printf("所得值为%d\n",s);
}