计算正方形面积的程序

2025年1月8日 | 1 分钟阅读

正方形的面积是指正方形所占据的空间大小。正方形是指一个平面图形,它有四条相等长度的直边和四个直角。

公式

area = width � height
Area of square will be calculated as : 
area = side2
since width = height; 

算法

  1. 将正方形任意一条边的高度定义为“s”。
  2. 通过将 s 乘以 s 来计算正方形的面积。
  3. 将 area_square 定义为正方形的面积。

复杂度

O(1)


解决方案

C 语言程序

输出

Area of the square=169    

PHP 程序

输出

Area of the square=169  

Java 程序

输出

Area of the square=169

C# 程序

输出

Area of the square=169

Python 程序

输出

Area of the square=169  
 
下一主题#