#include<stdio.h>
int main(void)
{
int a, b, n, i, j;
printf("please enter n: ");
scanf("%d",&n);
for(a=0,i=1; i<=n; i++)//做1+2+3+...+n的循环
{
a+=i;
}
for(b=1,j=1; j<=n; j++)//做1*2*3...*n的循环
{
b*=j;
}
printf("1+2+3+...+n=%d\n",a);
printf("1*2*3...*n=%d\n",b);
return 0;
}
新手写的,请多指教!!!