Thread: A hint, but no answer please!

  1. #1
    Registered User
    Join Date
    Nov 2008

    A hint, but no answer please!

    Ok, this is probably a really easy problem, but I've been trying for 2.5 days to work on it, with no luck. Any hints would be helpful, but no answers, please.

    "Given threee points (x1, y1), (x2, y2), and (x3, y3), write a program to check if all the three points fall on one straight line."

    My math skills are lacking in this area, so even if I were to just do it mathematically without a computer, I would just physically plot the points and see if they fell on the same line. I know these equations, but I don't know how to fit them in to this problem:



    My only idea is to figure out some type of relationship that exists between (x1,y1) and (x2, y2) and see if the same relationship exists between those and (x3, y3), but I'm not sure how to go about doing that. Thanks, y'all!

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    I don't know how much of a hint I can give, since "m = (y2-y1)/(x2-x1)" is in fact the answer to the problem.

  3. #3
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Consider that only points on a line satisfy the equation of a line. And this equation might help (highlight if you get stuck. y - y1 = m(x - x1))

  4. #4
    Registered User
    Join Date
    Jan 2009
    lol! yr 10 maths!

    you cannot check one point at a time, you have to check x then y and if both of them check out then the point is on the line.

    you do this by : (i hope you meant no C answers)

    substituting y for 0 (in y=mx+b) and if m*the gradient of the line + the y intercept = 0 then you check by subbing x for 0 and if y = b (m*the gradient of the line[x] = 0) then you have your self a point on the line!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Looking for constructive criticism
    By wd_kendrick in forum C Programming
    Replies: 16
    Last Post: 05-28-2008, 09:42 AM
  2. One quick question...
    By Kross7 in forum C++ Programming
    Replies: 10
    Last Post: 04-13-2007, 09:50 PM
  3. Tic Tac Toe program...
    By Kross7 in forum C++ Programming
    Replies: 12
    Last Post: 04-12-2007, 03:25 PM
  4. code help :)
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 02-28-2002, 01:12 PM
  5. Replies: 22
    Last Post: 11-08-2001, 11:01 PM