Someone asked me on the snow watching forum. So I wrote this code by the way.
Q: I encountered this problem when writing code. Set the points A (100,100) and B (200,200) to a straight line. How can I get, b: All vertices in a straight line connected by two points. The brother can give a formula. Thank you first.
A: We can use the vectors to obtain the result in collinearity. I learned this in middle school:
If three points A (x1, Y1) B (X2, Y2) C (X3, Y3) are collocated, the AB CB vector is collocated. (X1 * y2-x2 * Y1) = (x1 * y3-x3 * Y1)
The following is the C language code. Compiled in tc2.1.
# Include <stdio. h>
Main ()
{
Int I;
/* A (ARR [0] [0], arr [1] [0]) B (ARR [0] [1], arr [1] [1]) */
Int arr [2] [2] ={{ 100,200 },{ 100,200 }};
/* C (arrin [0] [0], arrin [1] [0]) */
Int arrin [2] [1];
Clrscr ();
For (I = 0; I <3; I ++ ){
Printf ("Please input two interget. \ n ");
/* Input C */
Scanf ("% d", & arrin [0] [0], & arrin [1] [0]);
If (ARR [0] [0] * arrin [1] [0]-arrin [0] [0] * arr [1] [0]) = (ARR [0] [0] * arr [1] [1]-Arr [0] [1] * arr [1]
[0])
Printf ("the point C (% d) is on the line! \ N ", arrin [0] [0], arrin [1] [0]);
Else
Printf ("the point C (% d) is not on the line! \ N ", arrin [0] [0], arrin [1] [0]);
}
}