C++
/*
Author : _computer_engineers_
*/
#include
using namespace std;
int main()
{
int x[3], y[3];
double slope[2];
bool result;
// Input of Points
for(int i=0; i<3; i++)
{
cout << “Enter Point-” << (i+1) << ” : “;
cin >> x[i] >> y[i];
}
/*
If slope is equal, then points are linear as per Maths
Hence, it will not create Boomerang
*/
// Finding Slopes
slope[0] = (y[1]-y[0])/(x[1]-x[0]);
slope[1] = (y[2]-y[1])/(x[2]-x[1]);
// Checking Result
if(slope[0] == slope[1])
result = false;
else
result = true;
// Output
cout << “\nResult : ” << boolalpha << result << endl;
return 0;
}
Java
//Author : _computer_engineers_
import java.util.Scanner;
public class Boomerang {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int x[] = new int[3];
int y[] = new int[3];
double slope[] = new double[2];
boolean result;
// Input of Points
for(int i=0; i<3; i++) {
System.out.println(“Enter Point-” + (i+1) + ” : “);
x[i] = sc.nextInt();
y[i] = sc.nextInt();
}
/*
If slope is equal, then points are linear as per Maths
Hence, it will not create Boomerang
*/
// Finding Slopes
slope[0] = (y[1]-y[0])/(x[1]-x[0]);
slope[1] = (y[2]-y[1])/(x[2]-x[1]);
// Checking Result
if(slope[0] == slope[1])
result = false;
else
result = true;
// Output
System.out.println(“\nResult : ” + result);
sc.close();
}
}
Python
”’
Author : _computer_engineers_
”’
x = list()
y = list()
# Input of Points
for i in range(3):
print(“Enter Point-{} : “.format(i+1))
x.append(int(input()))
y.append(int(input()))
”’
If slope is equal, then points are linear as per Maths
Hence, it will not create Boomerang
”’
# Finding Slope
slope = list()
slope.append((y[1]-y[0])/(x[1]-x[0]))
slope.append((y[2]-y[1])/(x[2]-x[1]))
if slope[0] == slope[1]:
result = False
else:
result = True
# Output
print(“\nResult : {}”.format(result))