他是1/m^2 ,0应该不用考虑啊,我把负数加进去了,还是不对,要不你帮我去acm上看看去,号子和密码一样,最后一页题目倒数第九个
#include<stdio.h>
int main()
{
double t=0;
int m;
int i,j;
scanf("%d",&m);
if(m>=0)
for(j=1,i=1;i<=m;i++)
{
我问了哈出题的人,他说不用考虑0和负数,
这样就对了,他就把i定义成double型的就好了,这是为啥啊
#include<stdio.h>
int main()
{
double t=0,i;
int m;
int j;
scanf("%d",&m);
t=0;
for(j=1,i=1;i<=m;)
{
t+=j*1/(i*i*1.0);
j=-1;
i+=1;
}
printf("%.6lf\12",t);
return 0;
}
I am the voice of the next generation
Completely digital
Create synthetic auras