Thread: Rookie looking for help!

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Programming King Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Middle of NoWhere
    Posts
    320
    Code:
    int k=0;
    for(i=0; i<ARR_SIZE; i++)
        {
          while(k<ARR_SIZE){
                                          if (guess[i] == secretNumber[k] && help[i] != 'S'){
                                           help[i] = 'R';
                                           break;
                                            }
                                           k++;
                                          }
                                            k=0;
     
            for(j=0; j<=i-1; j++)
            {
                if(guess[i] == secretNumber[j])
                {
                    help[i] = 'S';
                }
            }
     
            if (help[i] != 'R' && help[i] != 'S')
                help[i] = '_';
        }
     
        printf("help: ", help[i]);
        for(i=0; i<ARR_SIZE; i++)
        {
            printf("%c ", help[i]);
        }
    }
    Now, it will run 100%..... :-)

    It will do _ RR_

    And i don't know why it should produce _SS_
    as you are replace R in case of right number but wrong place......

    Okay, so i think you want something like......
    Code:
    int k=0;
    for(i=0; i<ARR_SIZE; i++)
        {
                                                if (guess[i] == secretNumber[i] && help[i] != 'S'){
                                           help[i] = 'R';
                                           //break;
                                            }
                                           
            while(k<ARR_SIZE){
    
                if(guess[i] == secretNumber[k])
                {
                    help[i] = 'S';
                    break;
                }
           k++;
          }
       k=0;
     
            if (help[i] != 'R' && help[i] != 'S')
                help[i] = '_';
        }
     
        printf("help: ", help[i]);
        for(i=0; i<ARR_SIZE; i++)
        {
            printf("%c ", help[i]);
        }
    }
    Last edited by Mr.777; 03-10-2011 at 08:55 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Variable/pointer scope (rookie Qs)
    By twinbee in forum C Programming
    Replies: 3
    Last Post: 05-20-2010, 03:33 PM
  2. an uber-simple array/function question for a c rookie!
    By variable83 in forum C Programming
    Replies: 13
    Last Post: 12-06-2009, 01:24 PM
  3. Help a rookie
    By elrookie in forum C Programming
    Replies: 14
    Last Post: 06-14-2007, 10:28 AM
  4. Rookie pointer problem: 2 dimensions, malloc
    By GatesAntichrist in forum C Programming
    Replies: 11
    Last Post: 12-20-2005, 12:35 PM
  5. my code.. remember i am a rookie dont laugh
    By aubrey in forum C Programming
    Replies: 2
    Last Post: 11-24-2002, 10:08 PM