📜  如果给出角度,检查四边形是否有效

📅  最后修改于: 2021-10-23 08:58:36             🧑  作者: Mango

给定四个整数ABCD ,它们以度数表示四边形的四个角。任务是检查给定的四边形是否有效。

例子:

方法:
如果四个角之和等于 360 度,则四边形是有效的。

下面是上述方法的实现:

C++
// C++ program to check if a given
// quadrilateral is valid or not
#include 
using namespace std;
 
// Function to check if a given
// quadrilateral is valid or not
bool Valid(int a, int b, int c, int d)
{
    // Check condition
    if (a + b + c + d == 360)
        return true;
     
    return false;
}
 
// Driver code
int main()
{
    int a = 80, b = 70, c = 100, d = 110;
 
    if (Valid(a, b, c, d))
        cout << "Valid quadrilateral";
    else
        cout << "Invalid quadrilateral";
         
    return 0;
}


Java
// Java program to check if a given
// quadilateral is valid or not
class GFG
{
     
// Function to check if a given
// quadilateral is valid or not
public static int Valid(int a, int b,
                        int c, int d)
{
    // Check condition
    if (a + b + c + d == 360)
        return 1;
     
    return 0;
}
 
// Driver code
public static void main (String[] args)
{
    int a = 80, b = 70, c = 100, d = 110;
     
    if (Valid(a, b, c, d) == 1)
        System.out.println("Valid quadilateral");
    else
        System.out.println("Invalid quadilateral");
}
}
 
// This code is contributed
// by apurva_sharma244


Python3
# Python program to check if a given
# quadilateral is valid or not
 
# Function to check if a given
# quadilateral is valid or not
def Valid(a, b, c, d):
 
    # Check condition
    if (a + b + c + d == 360):
        return True;
     
    return False;
 
 
# Driver code
a = 80; b = 70; c = 100; d = 110;
 
if (Valid(a, b, c, d)):
    print("Valid quadilateral");
else:
    print("Invalid quadilateral");
 
# This code is contributed by Rajput-Ji


C#
// C# program to check if a given
// quadilateral is valid or not 
class GFG
{
 
// Function to check if a given
// quadilateral is valid or not
static bool Valid(int a, int b,
                  int c, int d)
{
    // Check condition
    if (a + b + c + d == 360)
        return true;
     
    return false;
}
 
// Driver code
public static void Main()
{
    int a = 80, b = 70, c = 100, d = 110;
     
    if (Valid(a, b, c, d))
        Console.WriteLine("Valid quadilateral");
    else
        Console.WriteLine("Invalid quadilateral");
}
}
 
// This code is contributed by nidhiva


PHP


Javascript


输出:
Valid quadilateral