以下是引用Afah在2011-10-19 13:20:23的发言:
#include
int main(void)
{
int i,j,sum;
double num;
/*1-100求和*/
for(i=0,sum=0;i<=100;i++)
sum+=i;
/*1-100奇数项的乘积*/
for(j=1,num=1;j<=35;j=j+2)
num*=j;
printf("1-100的和:sum= %d \n",sum);
printf("1-100奇数项的乘积:num= %.1lf \n",num);
getch();
}
#include <stdio.h>
#include<conio.h>
int main(void)
{
int i,j,sum;
double num;
/*1-100求和*/
for(i=0,sum=0;i<=100;i++)
sum+=i;
/*1-100奇数项的乘积*/
for(j=1,num=1;j<=100;j+=2)
num*=j;
printf("1-100的和:sum= %d \n",sum);
printf("1-100奇数项的乘积:num= %.1lf \n",num);
getch();
return 0;
}