Thread: Little guidance please...

  1. #1
    Registered User
    Join Date
    Sep 2006
    Location
    Iowa
    Posts
    14

    Little guidance please...

    I'm am writing a program to convert numbers to words. For example, 1893 would read "one eight nine three." I am assuming the number is less than a million. The only hint I have so far is to remember the % operator. Now, I am not asking for someone to write a program for me (unless they want to, ), but I would just like a little help and where to start. Frankly, I don't really know where to start (aside from printf and scanf statements).

  2. #2
    Registered User
    Join Date
    Apr 2006
    Posts
    2,149
    Here's a hint:

    1893%10=3
    1893/10=189
    189%10=9
    189/10=18
    ext.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  3. #3
    Registered User
    Join Date
    Sep 2006
    Location
    Iowa
    Posts
    14
    Ok, I kinda get what you're sayin. I'm tryin to write this now, and I get the concept, just tryin to figure out how to put that into terms as a variable as the program must do this for any number the user inputs.

  4. #4
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Well if you, ya know, cared about about helping yourself you could search the boards, since there is anothe question on this EXACT TOPIC right now, and it has been asked, give or take 42 million times.

  5. #5
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    Are you allowed to input this as a string?
    Cause this would be pretty easy if that was the case.
    Woop?

  6. #6
    Registered User
    Join Date
    Mar 2006
    Posts
    725
    A helluva damn lot of people appear to be asking this question lately. I wonder where all these folks come down from, eh...

    Anyway, if you want code:

    Code:
    #include <stdlib.h>
    #include <stdio.h>
    #define s(a,b) (a-b)
    #define p(x) putchar(n[s(0[v][s(-c/2,3)],48)*5+x]+1)
    
    const char*n="ydqn\37nmd\37\37svn\37\37sgqddentq\37ehud\37rhw\37\37rdudmdhfgsmh"
    "md\37sdm\37\37";int main(int c,char**v){return c>0?main(-1,v),0:c==-1?v=malloc(
    sizeof(char*)<<1),v[0]=malloc(60),fgets(v[0],40,stdin),sscanf(v[0],"%d",(int*)v[
    0]+10)?main(-6,v),0:puts("Illegal argument!"),getchar(),0:c%2?c<-4?main(c+2,v),0
    :0:v[0][s(s(,c)/2,3)]>=48&&v[0][s(s(,c)/2,3)]<=57?p(0),p(1),p(2),p(3),p(4),puts(
    ""),main(s(c,2),v),0:main(++c,v),0;}
    Good luck.
    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. Need some guidance.
    By Kinto in forum C Programming
    Replies: 10
    Last Post: 05-31-2009, 12:02 AM
  2. Guidance, please.
    By mattagrimonti in forum C Programming
    Replies: 2
    Last Post: 11-26-2008, 08:50 AM
  3. need guidance to connect to serial port
    By gnychis in forum Linux Programming
    Replies: 1
    Last Post: 06-02-2005, 10:10 AM
  4. Audio guidance.
    By Sebastiani in forum Windows Programming
    Replies: 6
    Last Post: 12-22-2002, 09:14 AM
  5. advice and possibly guidance
    By nazri81 in forum C++ Programming
    Replies: 3
    Last Post: 11-07-2002, 10:19 PM