Help With Creating Co - ordinates Program

This is a discussion on Help With Creating Co - ordinates Program within the C Programming forums, part of the General Programming Boards category; hey im new to this forum and also unfortunately new to c programming lol! i have only just started becoming ...

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    1

    Help With Creating Co - ordinates Program

    hey im new to this forum and also unfortunately new to c programming lol!
    i have only just started becoming use to using C Programming
    my question is:
    im designing a very simple (read: VERY Simple) C program which can take in the co-ordinates of any set of numbers similar to those found on a cartesian graph
    these co-ordinates (normally a set in the form of (x,y) &(a,b))are entered via the user but the program then needs to distinguish the difference between both X and A and then Y and B
    would guys have any tips out there on how to go about creating a program as such?
    it wood be such a great help!
    paul

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,765
    Well, you could start with a program which reads some input from the user, performs some kind of conversion, and prints the converted result back to the user.

    Then work on the next step of your assignment.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Mar 2006
    Posts
    725
    Have the user enter coordinates in pairs, and always handle coordinates in pairs, (x, y) style. That way, you'll never lose track. You could also create a struct (if you've learned that already) to store a coordinate pair, if you feel up to it.
    Code:
    #include <stdio.h>
    
    void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){
    puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9
    /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i]
    ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][
    t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. creating a program to help with modding
    By chuck22 in forum C++ Programming
    Replies: 9
    Last Post: 02-16-2006, 10:16 AM
  2. insufficient memory for tsr
    By manmohan in forum C Programming
    Replies: 8
    Last Post: 01-02-2004, 09:48 AM
  3. Date program starts DOS's date
    By jrahhali in forum C++ Programming
    Replies: 1
    Last Post: 11-24-2003, 05:23 PM
  4. creating a simple program to accept a password.
    By boy1015 in forum C++ Programming
    Replies: 11
    Last Post: 02-05-2002, 08:34 PM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21