Any "recommended" C programs to be used in a programming contest? Please help.

This is a discussion on Any "recommended" C programs to be used in a programming contest? Please help. within the C Programming forums, part of the General Programming Boards category; Dear administrators and members, A pleasant day to everyone, I hope everyone is doing ok upon reading this thread. I ...

  1. #1
    Registered User MarkSquall's Avatar
    Join Date
    Aug 2007
    Posts
    27

    Post Any "recommended" C programs to be used in a programming contest? Please help.

    Dear administrators and members,


    A pleasant day to everyone, I hope everyone is doing ok upon reading this thread. I don't know if it is okay to ask this, but I'll just try...I hope someone could help me create a C program problems that can be used in C programming contest, all in all I need nine (9) problems (3 for easy, 3 for medium, and 3 for difficult round), and the contestants are all freshmen. I kept on searching for the net, but all examples are more "advanced C" problems. I hope someone could give me some suggestions. Thank you very much to all and God bless.


    Respectfully yours,

    MarkSquall

  2. #2
    Captain - Lover of the C
    Join Date
    May 2005
    Posts
    341
    Do you have a layout in mind or some topics that you want covered? An example for the layout: I've seen contests where all input is contained in a file and the contestants are expected to output the results to another file.
    As for the topics, do you have concepts that were taught that you want covered in the contest like sorting, string algorithms, etc...?
    Or are you thinking more of the students designing their own algorithms like writing a program to find the first X number of primes?
    Don't quote me on that... ...seriously

  3. #3
    Registered User MarkSquall's Avatar
    Join Date
    Aug 2007
    Posts
    27

    Post Some topics in the contest I have in mind,

    Sir Brad0407,

    Thank you for your comments Sir, well I just want to have problems "rich" in repetition and selection control structures, functions and arrays (because majority of contestants have dealt with this topics in their lectures) I guess no need for an input to another file, i.e. the user will be the one to enter the input necessary, (ex. please enter a number, please enter a string, etc.).


    Thank you and more power!


    Yours truly,
    MarkSquall

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,184
    Well... you could write a dynamic array. Simple.
    Then you could turn your array into a little more difficult project by expanding it with VirtualAlloc, assuming you're using Windows.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  5. #5
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    I'm not sure how easy or hard you actually mean. This is for freshmen, so I don't think you want it too difficult. You said you wants loops, functions, and arrays.... I'll try to give you a range of topics, but I'm not sure if I'm classifying them according to their true level of difficulty. It should get you started, though.

    Super Easy:

    • Implement the C library function strcpy().
    • Write a function that accepts an unsigned int and returns the factorial of that number.
    • Write a function that accepts two unsigned integers and returns the result of their multiplication, however, direct multiplication and division (ie. * and /) are NOT allowed.


    Easy:

    • Write a program that continuously asks the user for a string. If the string matches "exit", then the program quits. If the string is a palindrome, the program should print "Palindrome". If the string is NOT a palindrome, the program should print the index on both sides where the characters does NOT match. (ie. "exit" causes exit. "radar" causes "Palindrome". "123541" produces "1 4" because string[1] and string[4] do NOT match.)
    • Write a function that accepts two signed integers a and b, and returns a % b, except the % operator may NOT be used. [Care to get exactly the same result as % could be part of the challenge.]
    • Write a program that accepts a float/double and converts it into a reduced fraction (ie. 12.25 would be 12 1/4). [We had the opposite question asked here on this forum.]


    Medium:

    • Write a program that reads in a set number of bank account records, sorts them by customer name, and prints them. Bank account records are made up of the following items: 8-digit integer account ID, customer name no longer than 30 chars, and the amount in the account. If customer names are the same between two accounts (because the customer has multiple accounts), the accounts in question are further sorted by their ID. Accounts are printed with all information.
    • Write a program that reads in a hexadecimal integer number and prints back it's positive and negative value on that system. (ie. On a 32-bit 2's complement system, 0xFFFFFFFF will result in 4294967295 and -1.). If the number is positive whether taken as signed or unsigned, multiply the number by -1. [This is rather easy. Some addition to this challenge with regard to signed and unsigned numbers would be good here.]
    • Write a program that reads in a set number of signed integers, and then divides them all by their GCD.


    Hard:

    • Implement a power function that takes in two signed integers a and b, and returns the result of a raised to the power of b as a double. Note: Both a and b can independently be negative. Write a program to accept two signed integers and test the function.
    • Write a program that reads in 5 signed integers that form a pattern where subsequent numbers are either greater than or less than their previous number by a certain unknown integer value. The program must output the next number in the pattern. For example, if the numbers 1, 2, 3, 4, and 5 are the input, then the output is 6. If the input is 1, 3, 5, 7, 9, then the output is 11. If the output is -3, -6, -9, -12, -15, then the output is -18. [This is probably easier than intended. To make it more difficult and probably at a more appropriate leve of difficultyl, allow for multiplication and division to affect the numbers instead of just addition and subtraction. To further complicate it, allow for the unknown factor to be a floating point number instead of an integer. To further complicate the challenge, allow for a complex patter made up of more than one simple pattern.]
    • Write a program that reads in two 3x3 matrices (in the form of 9 signed integers each), and prints the results of addition between the two matrices as well as the result of the dot product between the two matrices.


    Super Hard:

    • Write a bigint implementation in a program where the user may enter two 100-digit integers and request addition and or subtraction between those two numbers. [The implementation should be able to handle overflow with addition, and underflow with subtraction.]
    • Write a function that reads input from stdin until a newline or EOF is reached in the stream. The entire string should be stored inside a dynamically sized block of memory and returned by the function. The returned char * should be printed by the caller and then free()ed.
    • Write a program that is able to read an arbitrary amount of unsigned integers ended with an entry of -1. After reading in all of the integers, the program must calculate the mean, mode, median, variance and standard deviation of that set of numbers.
    Last edited by MacGyver; 12-10-2007 at 10:48 AM. Reason: Fixed error in palindrome example, clarified another.

  6. #6
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,184
    Some of that doesn't really fit into said c categories... second super hard is very easy and though maybe the dynamic part isn't so often found on the boards, the other is. Or a variant thereof. The first is super hard but not the second.
    The 3rd isn't that hard either, if you know how to calculate all that, of course. That's math and not programming.

    There's probably more too...
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  7. #7
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    The main focus is for freshmen students that have lectures on loops, control structure, arrays, etc. etc..

    Nowhere did he mention dynamic memory, memory management, pointers, advanced data types, etc. etc..

    If we were targetting this for gradudate students or those experienced with C, the basic questions would be more in line with the "super hard" ones.

    Incidentally, how about you make your own suggestions?

  8. #8
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,184
    I just find it that, even though the lack of all that, some of those super hard are still quite easy.
    I'm not a teacher, so I can't really think of much.
    Even so, everything I find easy would probably be hard for a newbie. Your suggestions aren't half bad, so... I'll leave it at that.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  9. #9
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Perhaps you're right and they all are too easy.

    Please offer some other suggestions. You don't have to be a teacher to come up with challenges for something like this. You have 1,277 posts as of this post here at cboard, plus you obviously learned something in terms of C/C++ prior to even making an account here, so you should be able to come up with something good for this.

    The OP could benefit by more challenges to choose from. Please reconsider.

  10. #10
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,184
    I can't say if they're very easy or hard for a newbie, but one thing I can think of (probably hard) is a function to detect if the machine is high or low endian.
    Maybe write a function that converts a number to a string without using integer-to-string functions? Probably hard.
    A slight hard program might be a simple calculator. Make one that can do basic calculations with +, -, * and /. Only integers. The calculator should also be able to handle any type of numbers, even if there are spaces here and there.
    And if you want to expand on that, extend the functionality so that it can support parenthesis. It might be something akin to writing a compiler (though far more simpler).
    I'll see if I can think of other things.
    Last edited by Elysia; 12-10-2007 at 09:07 AM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  11. #11
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Other suggestions (mostly assuming input files, I think):

    1. A program that reads in an ASCII "maze", with # representing walls, . representing paths, and an S for start and F for finish. The program should output whether there is a path/number of paths/a possible path/something like that.

    2. A program that reads in a table of function values, and then accepts an x value and outputs an interpolated y value.

    3. A simple syntax-checker (maybe just checks for () and [] pairs, with no improper nesting, like ([)] ).

    4. Process records in a file (maybe computing interest on saving accounts, or updating inventory, or ...)

    5. Print the 12x12 multiplication table (nicely formatted).

    I think this is in rough order from hard to easy.

  12. #12
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,184
    Well, create a small game that allows you to walk forwards or backwards through rooms (implement as a double linked list). You can also save that linked list to file and read it back properly later too.
    The rooms should contain a name and size.
    If you want to complicate it EVEN further, then you can create a game with rooms that allows you to walk east, west, north and south, to different rooms to reach the goal. You can also add health and traps in certain rooms. If health reaches 0, the hero dies.
    Hint: Add traps and damage they do into the list.
    You might also create a struct with hero information such as name, gender and health.
    Not the easiest thing to do. I'd call that pretty hard.
    Last edited by Elysia; 12-10-2007 at 11:23 AM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  13. #13
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Quote Originally Posted by Elysia View Post
    Well, create a small game that allows you to walk forwards or backwards through rooms (implement as a double linked list). You can also save that linked list to file and read it back properly later too.
    The rooms should contain a name and size.
    If you want to complicate it EVEN further, then you can create a game with rooms that allows you to walk east, west, north and south, to different rooms to reach the goal. You can also add health and traps in certain rooms. If health reaches 0, the hero dies.
    Hint: Add traps and damage they do into the list.
    You might also create a struct with hero information such as name, gender and health.
    Not the easiest thing to do. I'd call that pretty hard.
    Ah, yes....

    Spy
    vs.
    Spy

    NES

    http://www.youtube.com/watch?v=xhI5dHPYZjY


  14. #14
    Registered User MarkSquall's Avatar
    Join Date
    Aug 2007
    Posts
    27

    Thumbs up Thanks everyone!

    Dear Sirs,

    Thank you for all the suggestions you have given me (credits again to MacGyver and tabstop also to Elysia), I will definitely use those program problems maybe the next time we'll be having another C programming contest again. God bless and more power to all members and administrators.



    Respectfully yours,

    MarkSquall

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Expression Evaluator Contest
    By Stack Overflow in forum Contests Board
    Replies: 20
    Last Post: 03-29-2005, 09:34 AM
  2. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 03:17 PM
  3. WANTED: Contest Master
    By kermi3 in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-23-2003, 09:15 PM

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