Пример #1
0
int main(int argc, char* argv[]) {
	
	long long x1 = atof(argv[1]);
	long long y1 = atof(argv[2]);
	long long x2 = atof(argv[3]);
	long long y2 = atof(argv[4]);
	long long x3 = atof(argv[5]);
	long long y3 = atof(argv[6]);

	double x1_x2_length = get_side_length(x2, x1, y2, y1);
	double x2_x3_length = get_side_length(x3, x2, y3, y2);
	double x1_x3_length = get_side_length(x3, x1, y3, y1);

	double x1_x2_angle = get_angle(x1_x2_length, x2_x3_length, x1_x3_length);
	double x2_x3_angle = get_angle(x2_x3_length, x1_x3_length, x1_x2_length);
	double x1_x3_angle = get_angle(x1_x3_length, x1_x2_length, x2_x3_length);

	if(!is_a_triangle(x1_x2_length, x2_x3_length, x1_x3_length)) {
		printf("not a triangle\n");
		exit(0);
	}

	if(is_scalene(x1_x2_length, x2_x3_length, x1_x3_length))
		printf("scalene ");
	else
		printf("isosceles ");
	
	if(is_right(x1_x2_length, x2_x3_length, x1_x3_length))
		printf("right\n");
	
	if(is_acute(x1_x2_angle, x2_x3_angle, x1_x3_angle))
		printf("acute\n");
	else
		printf("obtuse\n");

	/*printf("x1_x2_length: %f\n", x1_x2_length);
	printf("x2_x3_length: %f\n", x2_x3_length);
	printf("x1_x3_length: %f\n", x1_x3_length);
	printf("x1_x2_angle: %f\n", x1_x2_angle);
	printf("x2_x3_angle: %f\n", x2_x3_angle);
	printf("x1_x3_angle: %f\n", x1_x3_angle);*/
	
	return 0;
}
Пример #2
0
/*******************************************************************************************
 * NAME :             print_classification()
 *
 * DESCRIPTION :      Prints the classification of the triangle to the console.
 *                    Eg: "isosceles right\n", or "scalene obtuse\n", etc.
 */
void print_classification(void) {
  if (is_isosceles()) {
    printf("isosceles ");
  } else if (is_scalene()) {
    printf("scalene ");
  } else {
    assert(0); /* something went horribly wrong, didn't it */
  }

  if (is_acute()) {
    printf("acute\n");
  } else if (is_right()) {
    printf("right\n");
  } else if (is_obtuse()) {
    printf("obtuse\n");
  } else {
    assert(0); /* something went horribly wrong, didn't it */
  }
  return;
}