这是我在 C 语言中的第一个程序。当我运行它时,它发现的斜边很大。我将 A 面和 B 面输入为 2,输出为130899047838401965660347085857614698509581032940206478883553280.000000
. 我做错了什么?
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int die(const char *msg);
double hypotenuse(double side0, double side1);
int main()
{
double a, b, c;
printf("Enter side A: ");
if (scanf_s("%1f", &a) != 1)
die("input failure");
printf("Enter side B: ");
if (scanf_s("%1f", &b) != 1)
die("input failure");
c = hypotenuse(a, b);
printf("The hypotenuse is %f\n ", c);
}
int die(const char *msg)
{
printf("Fatal Error: %s\n", msg);
exit(1);
}
double hypotenuse(double side0, double side1)
{
return sqrt((side0 * side0) + (side1 * side1));
}