sistema.c

Output:

 Sistema lineare
 ┌
 │ a x + b y = e
 ┤
 │ c x + d y = f
 └
 Inserisci a b e: 1 2 3
 Inserisci c d f: 4 5 6
 ┌
 │ x = -1.000000
 ┤
 │ y = 2.000000
 └

Listato:

#include <stdio.h>

main() {
	double a, b, c, d, e, f, D, Dx, Dy, x, y;

	printf(" Sistema lineare\n");
	printf(" Ú\n");
	printf(" ³ a x + b y = e\n");
	printf(" ´\n");
	printf(" ³ c x + d y = f\n");
	printf(" À\n");

	printf(" Inserisci a b e: ");
	scanf("%lf %lf %lf", &a, &b, &e);

	printf(" Inserisci c d f: ");
	scanf("%lf %lf %lf", &c, &d, &f);

	D = a * d - b * c;
	Dx = e * d - b * f;
	Dy = a * f - e * c;

	if (D != 0) {
		x = Dx / D;
		y = Dy / D;
		printf(" Ú\n");
		printf(" ³ x = %lf\n", x);
		printf(" ´\n");
		printf(" ³ y = %lf\n", y);
		printf(" À\n");
	} else if (Dx !=0 || Dy != 0) {
		printf("\n Sistema impossibile\n");
	} else {
		printf("\n Sistema indeterminato\n");
	}

	return 0;
}