累加求和

2015-04-29 03:11:05 -0400
#include<stdio.h>
void main()
{
int sum1,sum2;
float sum3,sum;
sum1=0;
sum2=0;
sum3=0;
int i;
for(i=1;i<=100;i++)
sum1+=i;
for(i=1;i<=50;i++)
sum2+=i*i;
for(i=1;i<=10;i++)
sum3+=1.0/i;
sum=sum1+sum2+sum3;
printf("累加求和=%f\n",sum);
}
«Newer      Older»

----Comments(1)----
贤者之石 (@19970501) | @ at 2015-04-29 03:43:
c++?
Comment:
Name:

Back to home

Subscribe | Register | Login | N