杭电2007题哪错了?
#include<stdio.h>#include<math.h>inta,b,s,p;voidmain(){while(scanf("%d%d",&a,&b)!=EOF...
#include <stdio.h>
#include <math.h>
int a,b,s,p;
void main ()
{ while (scanf ("%d%d",&a,&b)!=EOF)
{int p=0; int s=0;
for (a;a<=b;a++)
{
if (a%2==1)
s=s+a*a*a;
else
p=p+a*a;
}
printf ("%d %d\n",p,s);
}
} 展开
#include <math.h>
int a,b,s,p;
void main ()
{ while (scanf ("%d%d",&a,&b)!=EOF)
{int p=0; int s=0;
for (a;a<=b;a++)
{
if (a%2==1)
s=s+a*a*a;
else
p=p+a*a;
}
printf ("%d %d\n",p,s);
}
} 展开
1个回答
展开全部
//要考虑的问题还真多,试了两下,才弄出来,AC掉了,你对比一下吧
#include <stdio.h>
int main ()
{
int a,b,s,p,t;
while (scanf ("%d%d",&a,&b)!=EOF)
{ p=0;
s=0;
if(a>b) {t=a;a=b;b=t;}
for (;a<=b;a++)
{
if (a==a/2*2)
p=p+a*a;
else
s=s+a*a*a;
}
printf ("%d %d\n",p,s);
}
return 0;
}
#include <stdio.h>
int main ()
{
int a,b,s,p,t;
while (scanf ("%d%d",&a,&b)!=EOF)
{ p=0;
s=0;
if(a>b) {t=a;a=b;b=t;}
for (;a<=b;a++)
{
if (a==a/2*2)
p=p+a*a;
else
s=s+a*a*a;
}
printf ("%d %d\n",p,s);
}
return 0;
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询