<math.h>
头文件中。double hypot(double x, double y);
HUGE_VAL
。#include <stdio.h> #include <math.h> int main() { double sides[][2] = { {3.0, 4.0}, {5.0, 12.0}, {8.0, 15.0} }; double result; for(int i = 0; i < 3; i++) { result = hypot(sides[i][0], sides[i][1]); printf("For sides %.2f and %.2f, the hypotenuse is: %.2f\n", sides[i][0], sides[i][1], result); } return 0; }输出结果为:
For sides 3.00 and 4.00, the hypotenuse is: 5.00
For sides 5.00 and 12.00, the hypotenuse is: 13.00
For sides 8.00 and 15.00, the hypotenuse is: 17.00
本文链接:http://task.lmcjl.com/news/6058.html