OpenJudge exercises (C ++) -- question 4072: judge whether multiple points are in the same straight line
Question:
-
Total time limit:
-
1000 ms
-
Memory limit:
-
65536kB
-
Description
-
There are N (1 <= n <= 100) <span = ""> points that do not overlap with each other, and their coordinates (xi, yi) are given ), ask if these points are in the same straight line.
-
Input
-
The first row is the number of T (1 <= T <= 100), followed by T group data. The first row of each group is the number of N data points of the group, followed by N rows, each line represents the coordinate of a point, which consists of two numbers separated by spaces.
-
Output
-
There are T rows. Each row corresponds to a set of input data. If the data points in the group are in the same line, the row outputs True; otherwise, the output is False.
-
Sample Input
-
130 02 21 1
-
Sample output
-
True
Solution:
#include<iostream>#include<stdio.h>using namespace std;int main(){int T;cin>>T;int True[T];double a[T][1000];double b[T][1000];int c[T];for(int i=0;i<t;i++) cin="">>c[i];for(int j=0;j<c[i];j++) cin="">>a[i][j]>>b[i][j];}}for(int i=0;i<t;i++) int="" h="1;h<c[i];h++)">2&&(b[i][1]-b[i][0])*(a[i][h]-a[i][0])!=(b[i][h]-b[i][0])*(a[i][1]-a[i][0])){True[i]=0;//cout<<a[i][0]*b[i][h]<<"and"<<a[i][h]*b[i][0]<<endl; else="" return="" pre=""><p></p> </a[i][0]*b[i][h]<<"and"<<a[i][h]*b[i][0]<<endl;></t;i++)></c[i];j++)></t;i++)></stdio.h></iostream>