Skip to content

Instantly share code, notes, and snippets.

@iporsut
Created August 16, 2012 10:58
Show Gist options
  • Save iporsut/3369269 to your computer and use it in GitHub Desktop.
Save iporsut/3369269 to your computer and use it in GitHub Desktop.
ZOJ 1241 : Geometry Made Simple
#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