杭电acm 2092 帮我找出错误,谢谢; 不要正确答案
#include<stdio.h>#include<math.h>intmain(void){intn,m;//n+m*;doubledelta,x;constdoubl...
#include <stdio.h>
#include <math.h>
int main(void)
{
int n, m; // n + m *;
double delta, x;
const double zero = 0.0001;
while(scanf("%d%d", &n, &m) == 2)
{
if(!n || !m)
break;
delta = 1.0*(n*n - 4*m);
if(fabs(delta) < zero)
{
x = -n / -2;
if((x - (int)x) < zero)
{
printf("Yes\n");
continue;
}
}
else if(delta < 0)
{
printf("No\n");
continue;
}
else if(delta > 0)
{
delta = sqrt(delta);
x = (-n + delta) / -2;
if(fabs(x - (int)x) < zero)
{
printf("Yes\n");
continue;
}
x = (-n - delta) / -2;
if(fabs(x - (int)x) < zero)
{
printf("Yes\n");
continue;
}
}
printf("No\n");
}
return 0;
} 展开
#include <math.h>
int main(void)
{
int n, m; // n + m *;
double delta, x;
const double zero = 0.0001;
while(scanf("%d%d", &n, &m) == 2)
{
if(!n || !m)
break;
delta = 1.0*(n*n - 4*m);
if(fabs(delta) < zero)
{
x = -n / -2;
if((x - (int)x) < zero)
{
printf("Yes\n");
continue;
}
}
else if(delta < 0)
{
printf("No\n");
continue;
}
else if(delta > 0)
{
delta = sqrt(delta);
x = (-n + delta) / -2;
if(fabs(x - (int)x) < zero)
{
printf("Yes\n");
continue;
}
x = (-n - delta) / -2;
if(fabs(x - (int)x) < zero)
{
printf("Yes\n");
continue;
}
}
printf("No\n");
}
return 0;
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询