Thread: easy question

  1. #1
    Registered User
    Join Date
    Sep 2006
    Location
    vancouver wa
    Posts
    221

    easy question

    what im trying to do is ask for input
    say 123 then have it display one two three in english

    i think im on the right track but when the digits are extracted one by one the number = 0 then how can case work then?

    Code:
    #include 
    #include 
    
    int main(int argc, char *argv[])
    {
    
    int number,right,placecount;
    
    
    printf("\n%25cNumbers to words converter\n",0);
    
    
    
    printf("\nEnter the number:");
    scanf("%i", &number);
    
    do
    {
    
    right = number %10;
    number = number /10;
    ++placecount;
    }
    
    while(number!=0);
    
    
    
    do
    {
    switch(right)
    {
    case '0':
    printf("zero\n");
    break;
    
    case '1':
    printf("one\n");
    break;
    
    
    default:
    break;
    
    
    } 
    }
    
    
    while(placecount >0);
    
    system("PAUSE"); 
    return 0;
    
    
    }

  2. #2
    Registered User
    Join Date
    Mar 2006
    Posts
    725
    Huh?

    Can you ask a clearer question?

    Oh, and you should really format your code. It doesn't look very, erm, readable right now.
    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;}

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    This is a dupe thread. He's already been told what to do here and ignored it.


    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,663
    Agreed - closed (both of them)
    Post a proper question with code tags and formatting.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. easy Vector contructor question
    By noodle24 in forum C++ Programming
    Replies: 5
    Last Post: 04-21-2006, 07:43 PM
  2. Another Embarassingly Easy Question
    By almo89 in forum C Programming
    Replies: 2
    Last Post: 02-11-2006, 04:59 PM
  3. This is hopefully an extremely easy question...
    By rachaelvictoria in forum C Programming
    Replies: 2
    Last Post: 11-07-2005, 01:36 AM
  4. 4 easy question
    By Zeratulsdomain in forum C++ Programming
    Replies: 2
    Last Post: 10-15-2005, 10:43 PM
  5. Easy Question
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 08-12-2002, 12:19 PM