code pour vérifier si un triangle est valide ou non

// Java implementation to check
// if three points form a triangle
import java.io.*;
import java.util.*;
 
class GFG {
     
// Function to check if three
// points make a triangle
static void checkTriangle(int x1, int y1,
                          int x2, int y2,
                          int x3, int y3)
{
 
    // Calculation the area of
    // triangle. We have skipped
    // multiplication with 0.5
    // to avoid floating point
    // computations
    int a = x1 * (y2 - y3) +
            x2 * (y3 - y1) +
            x3 * (y1 - y2);
 
    // Condition to check if
    // area is not equal to 0
    if (a == 0)
        System.out.println("No");
    else
        System.out.println("Yes");
}    in C++ Standard Template Library (STL)
    Modulo Operator (%) in C/C++ with Examples

5th Floor, A-118,
Sector-136, Noida, Uttar Pradesh - 201305
[email protected]

    Company
    About Us
    Careers
    Privacy Policy
    Contact Us
    Copyright Policy

    Learn
    Algorithms
    Data Structures
    Languages
    CS Subjects
    Video Tutorials

    Web Development
    Web Tutorials
    HTML
    CSS
    JavaScript
    Bootstrap

    Contribute
    Write an Article
    Write Interview Experience
    Internships
    Videos

@geeksforgeeks , Some rights reserved
Lightbox
Start Your Coding Journey Now!
×
Search Term:“
”
1

// Java implementation to check

2

// if three points form a triangle

3

import java.io.*;

4

import java.util.*;

5

 

6

class GFG {

7

     

8

// Function to check if three

9

// points make a triangle

10

static void checkTriangle(int x1, int y1,

11

                          int x2, int y2,

12

                          int x3, int y3)

13

{

14

 

15

    // Calculation the area of

16

    // triangle. We have skipped

17

    // multiplication with 0.5

18

    // to avoid floating point

19

    // computations

20

    int a = x1 * (y2 - y3) +

21

            x2 * (y3 - y1) +

22

            x3 * (y1 - y2);

23

 

24

    // Condition to check if

25

    // area is not equal to 0

26

    if (a == 0)

27

        System.out.println("No");

28

    else

29

        System.out.println("Yes");

30

}

31

 

32

// Driver code

33

public static void main(String[] args)

34

{

35

    int x1 = 1, y1 = 1,

36

        x2 = 2, y2 = 2,

37

        x3 = 3, y3 = 3;

38

    checkTriangle(x1, y1, x2, y2, x3, y3);
 
// Driver code
public static void main(String[] args)
{
    int x1 = 1, y1 = 1,
        x2 = 2, y2 = 2,
        x3 = 3, y3 = 3;
    checkTriangle(x1, y1, x2, y2, x3, y3);
}
}
 
Scary Shark