等边三角形的周长与面积

 

#include<stdio.h>
#include<math.h>

int main(void)
{
  double length = 0;  // 边长
  double s = 0;  // 面积
  double perimeter = 0;  // 周长
  
  printf("Please enter the length of the Equilateral triangle (cm):\n");
  scanf("%lf", &length);
  
  s = length*length*sqrt(3) / 2;
  perimeter = 3 * length;

  printf("The area of this triangle is %f (cm^2).\n",s);
  printf("The perimeter of this triangle is %f (cm).", perimeter);

  return 0;
}

说点什么

avatar

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

  Subscribe  
提醒