给定平行四边形的边,计算周长。
示例:
输入:a = 10,b = 8
输出:36.00
输入:a = 25.12,b = 20.4
输出:91.04
平行四边形的对边长度相等且平行。两角相等,但不一定为 90 度。平行四边形的周长可以计算为两条相邻边之和,每条边乘以 2。
计算平行四边形周长的公式:(2*a)+(2*b)
// C Program to calculate the
// Circumference of a Parallelogram.
#include <stdio.h>
float circumferenceparallelogram(float a, float b)
{
return ((2 * a) + (2 * b));
}
int main()
{
float a = 10, b = 8;
printf("Circumference of a given Parallelogram is : %.2f",
circumferenceparallelogram(a, b));
return 0;
}
输出 :
给定平行四边形的周长为:36.0
时间复杂度: O(1)
辅助空间: O(1)
如果您喜欢此文章,请收藏、点赞、评论,谢谢,祝您快乐每一天。