#include <stdio.h>
//Reference: https://m...content-available-to-author-only...m.com/Collinear.html
typedef struct Point {
float x,//abscisa
y;//ordonata
} TPoint;
//method number#2
/*
Sarrus Rule:
x1 y1 1
A = x2 y2 1
x3 y3 1
x1 y1 1
x2 y1 1
x1y2 + x2y3 + x3y1 - x3y2 - x1y3-x2y1 = x1(y2-y3) - y1(x2-x3) + (x2y3-x3y2)
*/
int checkCollinearity(TPoint P1, TPoint P2, TPoint P3) {
return (P1.x*(P2.y-P3.y) - P1.y*(P2.x-P3.x) + P2.x*P3.y - P2.y*P3.x);
}
int main(int argc, char const *argv[]) {
TPoint P[3];
for(int i = 0; i < 3; ++i) {
scanf("%f %f",&P
[i
].
x, &P
[i
].
y); }
if(P[0].x == P[1].x || P[0].x == P[2].x) {
if(P[2].x == P[0].x) {
printf("Collinear Points.\n"); } else {
printf("No Collinear Points.\n"); }
//compute the slope of the line AB
//y2-y1/x2-x1
} else {
if( (P[1].y - P[0].y)/(P[1].x - P[0].x) == (P[2].y - P[1].y)/(P[2].x - P[1].x)) {
printf("Collinear Points.\n"); } else {
printf("No Collinear Points.\n"); }
}
if(checkCollinearity(P[0],P[1],P[2]) == 0) {
printf("Collinear Points.\n"); } else {
printf("No Collinear Points.\n"); }
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgovL1JlZmVyZW5jZTogaHR0cHM6Ly9tLi4uY29udGVudC1hdmFpbGFibGUtdG8tYXV0aG9yLW9ubHkuLi5tLmNvbS9Db2xsaW5lYXIuaHRtbAoKdHlwZWRlZiBzdHJ1Y3QgUG9pbnQgewogICAgZmxvYXQgeCwvL2Fic2Npc2EKICAgICAgICAgIHk7Ly9vcmRvbmF0YQp9IFRQb2ludDsKCi8vbWV0aG9kIG51bWJlciMyCi8qClNhcnJ1cyBSdWxlOgogICAgeDEgeTEgMQpBID0geDIgeTIgMQogICAgeDMgeTMgMQogICAgeDEgeTEgMQogICAgeDIgeTEgMQogICAgeDF5MiArIHgyeTMgKyB4M3kxIC0geDN5MiAtIHgxeTMteDJ5MSA9IHgxKHkyLXkzKSAtIHkxKHgyLXgzKSArICh4MnkzLXgzeTIpCiovCmludCBjaGVja0NvbGxpbmVhcml0eShUUG9pbnQgUDEsIFRQb2ludCBQMiwgVFBvaW50IFAzKSB7CgogICAgcmV0dXJuIChQMS54KihQMi55LVAzLnkpIC0gUDEueSooUDIueC1QMy54KSArIFAyLngqUDMueSAtIFAyLnkqUDMueCk7Cn0KCmludCBtYWluKGludCBhcmdjLCBjaGFyIGNvbnN0ICphcmd2W10pIHsKCiAgVFBvaW50IFBbM107CgogIGZvcihpbnQgaSA9IDA7IGkgPCAzOyArK2kpIHsKICAgICBwcmludGYoIlBvaW50IyVkXG4iLGkrMSk7CiAgICAgc2NhbmYoIiVmICVmIiwmUFtpXS54LCAmUFtpXS55KTsKICB9CiAgaWYoUFswXS54ID09IFBbMV0ueCB8fCBQWzBdLnggPT0gUFsyXS54KSB7CgogICAgIGlmKFBbMl0ueCA9PSBQWzBdLngpIHsKICAgICAgICBwcmludGYoIkNvbGxpbmVhciBQb2ludHMuXG4iKTsKICAgICB9ICBlbHNlIHsKICAgICAgICBwcmludGYoIk5vIENvbGxpbmVhciBQb2ludHMuXG4iKTsKICAgICB9CiAgICAgLy9jb21wdXRlIHRoZSBzbG9wZSBvZiB0aGUgbGluZSBBQgogICAgIC8veTIteTEveDIteDEKICB9IGVsc2UgewogICAgIGlmKCAoUFsxXS55IC0gUFswXS55KS8oUFsxXS54IC0gUFswXS54KSA9PSAoUFsyXS55IC0gUFsxXS55KS8oUFsyXS54IC0gUFsxXS54KSkgewogICAgICAgICBwcmludGYoIkNvbGxpbmVhciBQb2ludHMuXG4iKTsKICAgICB9IGVsc2UgewogICAgICAgICBwcmludGYoIk5vIENvbGxpbmVhciBQb2ludHMuXG4iKTsKICAgICB9CiAgfQoKICBpZihjaGVja0NvbGxpbmVhcml0eShQWzBdLFBbMV0sUFsyXSkgPT0gMCkgewogICAgICAgICBwcmludGYoIkNvbGxpbmVhciBQb2ludHMuXG4iKTsKICB9IGVsc2UgewogICAgICAgICBwcmludGYoIk5vIENvbGxpbmVhciBQb2ludHMuXG4iKTsKICB9CiAgcmV0dXJuIDA7Cn0K