给定a和b是四边形ABCD对角线AC和BD的长度,四边形的面积为s 。任务是找到Varignon平行四边形PQRS的周长和面积。
注:当我们加入任何四边形的边的中点,新的四边形内部形成有将永远是一个平行四边形,这paralleogram称为Varignon的paralleogram在法国数学家皮埃尔·伐里农命名。因此,PQRS将是一个平行四边形,因为它是通过连接四边形ABCD的中点而形成的,如下所示:
例子:
Input: a = 7, b = 8, s = 10
Output: Perimeter = 15, Area = 5
方法: Varignon平行四边形PQRS的周长等于四边形ABCD对角线长度的总和。
因此,周长= a + b ,其中a和b是对角线AC和BD的长度。
同样,Varignon平行四边形的面积始终是四边形ABCD面积的一半。
因此, Area = s / 2 ,其中s是四边形ABCD的面积。
下面是上述方法的实现:
C
// C program to find the perimeter and area
#include
// Function to find the perimeter
float per( float a, float b )
{
return ( a + b );
}
// Function to find the area
float area( float s )
{
return ( s/2 );
}
// Driver code
int main()
{
float a = 7, b = 8, s = 10;
printf("%f\n",
per( a, b ));
printf("%f",
area( s ));
return 0;
}
Java
// Java code to find the perimeter and area
import java.lang.*;
class GFG {
// Function to find the perimeter
public static double per(double a, double b)
{
return (a + b);
}
// Function to find the area
public static double area(double s)
{
return (s / 2);
}
// Driver code
public static void main(String[] args)
{
double a = 7, b = 8, s = 10;
System.out.println(per(a, b));
System.out.println(area(s));
}
}
Python3
# Python3 code to find the perimeter and area
# Function to find the perimeter
def per( a, b ):
return ( a + b )
# Function to find the area
def area( s ):
return ( s / 2 )
# Driver code
a = 7
b = 8
s = 10
print( per( a, b ))
print( area( s ))
C#
// C# code to find the perimeter and area
using System;
class GFG {
// Function to find the perimeter
public static double per(double a, double b)
{
return (a + b);
}
// Function to find the area
public static double area(double s)
{
return (s / 2);
}
// Driver code
public static void Main()
{
double a = 7.0, b = 8.0, s = 10.0;
Console.WriteLine(per(a, b));
Console.Write(area(s));
}
}
PHP
Javascript
输出:
15
5