Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

code to check if a triangle is valid or not

// 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
feedback@geeksforgeeks.org

    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);
}
}
 
Comment

PREVIOUS NEXT
Code Example
Typescript :: flights starting from in india 
Typescript :: how to append different lists in installed apps django 
Typescript :: python unix get 5 minuts from now 
Typescript :: function call in Angular using typescript creates infinite loop 
Typescript :: Ionic toast animation 
Typescript :: How many arguments are in this function call? range(0, 100, 5) 20 
Typescript :: ignoring header x-firebase-locale because its value was null. flutter 
Typescript :: Can we nested try statements in java 
Typescript :: CUSTOM_ELEMENTS_SCHEMA error occur while unit testing with jasmine and karma 
Typescript :: 4. In order to have proper integration of the pulse current it is desired that 
Typescript :: how to create nest without spec test filefile 
Typescript :: change css to scss in angular online 
Typescript :: representation of graph usig sets and hash in python 
Typescript :: typescript check if value is in enum 
Typescript :: github:Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15 in android 
Typescript :: split a column of lists pandas 
Typescript :: returning objects in alphabetical order in ruby 
Typescript :: How to separate two similar names from two lists in Python 
Typescript :: The dialect mongodb+srv is not supported. Supported dialects feathers 
Cpp :: fast input output cpp 
Cpp :: std logic vhdl 
Cpp :: celsius to kelvin formula 
Cpp :: torch cuda is available 
Cpp :: c++ string erase all occurrences 
Cpp :: power function in O(log(n)) time c++ 
Cpp :: c++ random between two values 
Cpp :: Plus (programming language) 
Cpp :: what are various sections of process 
Cpp :: How to block window resize sfml c++ 
Cpp :: custom comparator in set of struct 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =