Accenture Coding Question | Straight Line | CodeWindow

Straight Line

Given a set of points in a plane, check weather the points lie on a straight line or not. If the lie on a straight line return the equation else return 0.

Input specification:
Input 1: First Line contains no of points in the plane.
Input 2: Second line contains x,y coordinates of all the points which are divided with spaces.

Output Specification:
Equation of the line (str) if the points lie on a plane or 0(str).

Sample Input:
3
1 1 2 2 3 3

Output:
1x-1y=0

Explanation:
The three points here are [1,1],[2,2] and [3,3]. These lie on a line so it returned the equation.

Solution in Python 3:

Solution in C++ :

Solution in JAVA :

Output:

Recent Posts
Pages