View Code of Problem 42

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include<math.h>
int main() {
	float x1, x2,x;
	int a, b, c,d;
	scanf("%d %d %d", &a, &b, &c);
	d = pow(b, 2)-a * 4 * c;
	x1 = (-b + sqrt(d)) / (2 * a);
	x2 = (-b - sqrt(d)) / (2 * a);
	if (x1 > x2) {
		printf("%.2f %.2f", x1, x2);
	}
	else {
		x = x1;
		x1 = x2;
		x2 = x1;
		printf("%.2f %.2f", x1, x2);
	}
}

Double click to view unformatted code.


Back to problem 42