Open roberthsu2003 opened 1 month ago
#include <stdio.h>
#include <math.h>
int main(void) {
int a, b, c, d;
printf("請輸入直角三角形對邊:");
scanf(" %d", &a);
printf("請輸入直角三角形鄰邊:");
scanf(" %d", &b);
c = sqrt(a * a + b * b);
printf("直角三角形的斜邊:%d\n", c);
d = a + b + c;
printf("直角三角形的周長:%d\n", d);
return 0;
}
#include <stdio.h>
#include <math.h>
int main(void) {
int a, b, c, d;
printf("Please enter the perpendicular length:");
scanf(" %d", &a);
printf("Please enter the base length:");
scanf(" %d", &b);
c = sqrt(a * a + b * b);
printf("Right triangle Hypotenuse is:%d\n", c);
d = a + b + c;
printf("Right Triangle perimeter is:%d\n", d);
return 0;
}
#include<stdio.h>
#include<math.h>
int main(void){
int a,b,c;
printf("請輸入直角三角形的對邊:");
scanf("%d",&a);
printf("請輸入直角三角形的鄰邊:");
scanf("%d",&b);
c = sqrt(pow(a,2)+pow(b,2));
printf("直角三角形的鄰邊為%d\n",c);
printf("直角三角形的周長為%d\n",a+b+c);
return 0;
}
#include <math.h>
#include <stdio.h>
/*==================
求直角三角形的斜邊及周長
==================*/
int main(void) {
double Opposite_side, neighbor;
double hypotenuse, perimeter;
printf("請輸入直角三角形的對邊:");
scanf("%lf", &Opposite_side);
printf("請輸入直角三角形的鄰邊:");
scanf("%lf", &neighbor);
hypotenuse = hypot(Opposite_side, neighbor);
perimeter = Opposite_side + neighbor + hypotenuse;
printf("直角三角形的斜邊為:%.2f\n", hypotenuse);
printf("直角三角形的周長為:%.2f\n", perimeter);
return 0;
}
#include<stdio.h>
#include<math.h>
int main(void) {
int a,b;
printf("請輸入直角三角形的對邊:",a);
scanf("%d",&a);
printf("請輸入直角三角形的鄰邊:",b);
scanf("%d",&b);
double hypot = sqrt(a*a+b*b);
printf("直角三角形的斜邊是:%0.lf\n",hypot);
double p;
p = a+b+hypot;
printf("直角三角形的周長為:%0.lf\n",p);
return 0;
}
#include <stdio.h>
#include <math.h>
int main(void) {
int a, b, c, d;
printf("請輸入直角三角形對邊:");
scanf(" %d", &a);
printf("請輸入直角三角形鄰邊:");
scanf(" %d", &b);
c = sqrt(a * a + b * b);
printf("直角三角形的斜邊:%d\n", c);
d = a + b + c;
printf("直角三角形的周長:%d\n", d);
return 0;
}
輸入:
輸出: