roberthsu2003 / cAndC-

51 stars 17 forks source link

三角形斜邊和周長的計算 #48

Open roberthsu2003 opened 1 month ago

roberthsu2003 commented 1 month ago

輸入:

輸出:

截圖 2024-08-11 下午4 23 38
catode231 commented 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;
}
AICraig commented 1 month ago
#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;
}
jamduh commented 4 weeks ago
#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;
}
TonyWu-Taiwan commented 3 weeks ago
#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;
}
wenting1219 commented 3 weeks ago
#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;
}
Benson315-del commented 3 weeks 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;
}