Created
August 16, 2012 10:58
-
-
Save iporsut/3369269 to your computer and use it in GitHub Desktop.
ZOJ 1241 : Geometry Made Simple
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <math.h> | |
int a, b, c, count = 1; | |
double result; | |
int main() { | |
scanf("%d %d %d", &a, &b, &c); | |
while (a != 0 && b != 0 && c != 0) { | |
if (c == -1) { | |
printf("Triangle #%d\nc = %.3lf\n\n", count, sqrt((double)(a*a + b*b))); | |
} else if (a == -1) { | |
result = (double)(c*c - b*b); | |
if (result < 0) | |
printf("Triangle #%d\nImpossible.\n\n", count); | |
else | |
printf("Triangle #%d\na = %.3lf\n\n", count, sqrt(result)); | |
} else { | |
result = (double)(c*c - a*a); | |
if (result < 0) | |
printf("Triangle #%d\nImpossible.\n\n", count); | |
else | |
printf("Triangle #%d\nb = %.3lf\n\n", count, sqrt(result)); | |
} | |
count++; | |
scanf("%d %d %d", &a, &b, &c); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment