Case Competition Help !

This is a discussion on Case Competition Help ! within the C Programming forums, part of the General Programming Boards category; Just need a little help about how to approach this problem for my high school C-Club Case Competition about Scrolling ...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    3

    Unhappy Case Competition Help !

    Just need a little help about how to approach this problem for my high school C-Club Case Competition about Scrolling text:


    Your program should update the screen once a second as follows:

    When your program first starts it should display the first character of your message, in the right-most position of the display (position 7).
    After one second it should update the display by scrolling your message one character to the left (i.e. first character at position 6, second character at position 7).
    Your program should continue to update the display by scrolling your message one character per second until it has completely scrolled off the left end of the display.
    Once your message has scrolled off the display, your program should start again at the first step above, i.e. first character at position 7.
    Your program should continue this process until you quit the program.


    As an example, suppose your message is "dog". The following would appear on the screen, where each column is the corresponding position on the screen, and each row represents the updated screen after one second has elapsed:

    Code:
      
                                 d
                               do
                             dog              
                           dog
                         dog
                       dog
                     dog
                   dog
                   og
                   g
    
              -- note a completely blank display here for 1 second --
                
                      d
                    do
                  dog
                dog
            
      -- etc--
    Note that "dog" is not a valid message - while all the letters can be displayed on the screen, it does not meet the minimum length requirement.
    Last edited by kashahyah; 04-08-2008 at 03:26 PM. Reason: wrong format

  2. #2
    Registered User
    Join Date
    Jan 2008
    Posts
    287
    If this is for a competition, the purpose is *probably* to test your programming ability, not your ability to Google an answer or ask for help on forums. If you can't solve the problem on your own, then you probably don't deserve to win the competition (Sorry! I'm not saying you suck, but helping wouldn't really be in the spirit of a good competition.)

    I will say however that your example isn't consistent with your explanation of the problem. You're scrolling "dog" by two characters each time for the vast majority of the iterations. Shouldn't it be:
    Code:
          d
         do
        dog
       dog
      dog
     dog
    dog
    og
    g
    
          d
         do
        dog
    ...

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    3
    Quote Originally Posted by arpsmack View Post
    If this is for a competition, the purpose is *probably* to test your programming ability, not your ability to Google an answer or ask for help on forums. If you can't solve the problem on your own, then you probably don't deserve to win the competition (Sorry! I'm not saying you suck, but helping wouldn't really be in the spirit of a good competition.)

    I will say however that your example isn't consistent with your explanation of the problem. You're scrolling "dog" by two characters each time for the vast majority of the iterations. Shouldn't it be:
    Code:
          d
         do
        dog
       dog
      dog
     dog
    dog
    og
    g
    
          d
         do
        dog
    ...
    I really want to win. Winner gets an iMac.

  4. #4
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,158
    Quote Originally Posted by kashahyah View Post
    I really want to win. Winner gets an iMac.
    You think your greed will motivate us?

  5. #5
    Registered User
    Join Date
    Jan 2008
    Posts
    287
    You might have to modify this slightly to get it to work.
    Code:
    void print_string_scrolling(char *string) {
       int i;
       for (i = 0; i != USER_SAYS_STOP; i++) {
          printf(("      " + string + "      " + string + "      " + string + "      ") << i);
          system("pause a second");
       }
    }

  6. #6
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by arpsmack View Post
    You might have to modify this slightly to get it to work.
    Code:
    void print_string_scrolling(char *string) {
       int i;
       for (i = 0; i != USER_SAYS_STOP; i++) {
          printf(("      " + string + "      " + string + "      " + string + "      ") << i);
          system("pause a second");
       }
    }
    But of course shifting a string i places would cause it to do rot-i, surely? (ducks and runs very far away)

  7. #7
    Registered User
    Join Date
    Jan 2008
    Posts
    287
    Oh crap you're right!
    Code:
    printf(("      " + string + "      " + string + "      " + string + "      ")
       && (0xFFFFFFF0000000000000000000000000000 >> i));
    Fixed I think.

  8. #8
    Registered User NeonBlack's Avatar
    Join Date
    Nov 2007
    Posts
    435
    Thanks arpsmack. You're a programming master. How the hell do you know everything?
    Works brilliantly.
    I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo

  9. #9
    Registered User
    Join Date
    Apr 2008
    Posts
    3
    Quote Originally Posted by arpsmack View Post
    You might have to modify this slightly to get it to work.
    Code:
    void print_string_scrolling(char *string) {
       int i;
       for (i = 0; i != USER_SAYS_STOP; i++) {
          printf(("      " + string + "      " + string + "      " + string + "      ") << i);
          system("pause a second");
       }
    }
    Thanks. Should I write this function as "main" or just declare it in "main" ?
    Last edited by kashahyah; 04-10-2008 at 12:12 AM. Reason: wrong format

  10. #10
    Registered User
    Join Date
    Dec 2006
    Location
    Scranton, Pa
    Posts
    252
    Quote Originally Posted by kashahyah View Post
    I really want to win. Winner gets an iMac.
    . .. if you win by cheating, you've won nothing at all. If the contest exceeds your abilities, accept your limitations and allow someone deserving to win. That, is the noble thing to do.

  11. #11
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,335
    I wonder if the OP is posting from their school library, as the IP lookup seems to suggest.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Format Precision & Scale
    By mattnewtoc in forum C Programming
    Replies: 1
    Last Post: 09-16-2008, 10:34 AM
  2. Base converter libary
    By cdonlan in forum C++ Programming
    Replies: 22
    Last Post: 05-15-2005, 01:11 AM
  3. Creating pop up menus
    By Ti22 in forum C++ Programming
    Replies: 22
    Last Post: 01-18-2005, 08:27 PM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  5. Basic Data types continue
    By viryonia in forum C Programming
    Replies: 6
    Last Post: 03-10-2003, 09:21 AM

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