编写计算菱形面积的程序

5 Sept 2024 | 2 分钟阅读

在用不同编程语言编写计算菱形面积的程序之前,我们首先要了解什么是菱形以及计算它的面积的公式是什么?

什么是菱形?

菱形是多边形,其四条边长度相等,对边平行。

用不同编程语言计算菱形面积的程序

程序 1:用 C 语言编写程序

以上 C 程序的输出

Enter the 1st diagonal of the rhombus:5
Enter the 2nd diagonal of the rhombus:10
Area of the rhombus is: 25.0

程序 2:用 Java 语言编写程序

以上 Java 程序的输出

The Area of a rhombus in Java:
400

程序 3:用 PHP 编程语言编写程序。

以上 PHP 程序的输出

1200

程序 4:用 Python 编程语言编写程序。

以上 Python 程序的输出

600.0