fork download
  1. #include <stdio.h>
  2.  
  3. struct TPoint {
  4. double x,
  5. y;
  6. };
  7.  
  8. typedef struct TPoint TPoint;
  9.  
  10. int main() {
  11.  
  12. TPoint P[3];
  13.  
  14. int i;
  15.  
  16. for(i = 0; i < 3; ++i) {
  17.  
  18. printf("Point No. %d (Abs and Ord) -> ", i + 1);
  19.  
  20. scanf("%lf %lf", &P[i].x, &P[i].y);
  21. }
  22.  
  23. if(P[0].x == P[1].x || P[1].x == P[2].x) {
  24.  
  25. if(P[0].x == P[2].x) {
  26.  
  27. printf("%s\n", "The points are collinear!");
  28.  
  29. } else {
  30.  
  31. printf("%s\n", "The points are not collinear!");
  32.  
  33. }
  34.  
  35. } else if( (P[0].y - P[1].y) / (P[0].x - P[1].x) == (P[1].y - P[2].y)/(P[1].x - P[2].x) ) {
  36.  
  37. printf("%s\n", "The points are collinear!");
  38.  
  39. } else {
  40.  
  41. printf("%s\n", "The points are not collinear!");
  42. }
  43.  
  44. return(0);
  45. }
Success #stdin #stdout 0s 4544KB
stdin
1 2
2 3
3 4
stdout
Point No. 1 (Abs and Ord) -> Point No. 2 (Abs and Ord) -> Point No. 3 (Abs and Ord) -> The points are collinear!