#include <stdio.h>
#include <math.h>

main()
{
int a, b, c;
int x1 = 0, x2 = 0;
char ch;

do
{
printf("input(a, b, c) : ");
scanf("%d%d%d", &a, &b, &c);

ch = getchar();

printf("이차방정식 근 구하기 \n");

if (b * b - 4 * a * c >= 0)
{
x1 = (-b + sqrt(b * b - 4 * a * c)) / (2 * a);
x2 = (-b - sqrt(b * b - 4 * a * c)) / (2 * a);
printf("x1, = %d, x2 = %d\n", x1, x2);
}
else
printf("허근입니다.\n");

printf("continue?(y)");
ch = getchar();
}
while(ch == 'y');
}

+ Recent posts