New Contest C & C++ Welcome

This is a discussion on New Contest C & C++ Welcome within the Contests Board forums, part of the Community Boards category; The following is a link to the pdf containing the outlines for the contest . this contest is short and ...

  1. #1
    Banned
    Join Date
    Jun 2005
    Posts
    594

    New Contest C & C++ Welcome

    The following is a link to the pdf containing
    the outlines for the contest.


    this contest is short and very basic and good for beginners.

    because this contest like a two minute coding job
    the due date will be Aug 31, 3pm EST.

    the following is required by you in doing the coding:

    winner will be based on how well the code preforms
    and then method used to come about the answer.
    no commenting is required, but the code should be
    neat and readable.

    it will also be judge on its length. (non white space character only)

    code can be written in C or C++.

    feel free to PM me, or Message me on a messenger
    when you are ready to submit your code.

  2. #2
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    I'm guessing this is using console input and output? (ACM recently changed from console I/O to file I/O)

    edit: well if so, my output's a bit different (because there's no standard way to clear the screen), so it looks like this:
    Code:
    10
    10      30
    6
    6       14
    7
    7       18
    11
    11      35
    15
    15      55
    16
    16      61
    100
    100     945
    10000
    10000   942820
    1000
    1000    29820
    21
    21      91
    22
    22      98
    0
    as you can see, the input is mixed in. if that's alright, use the one I'm submitting now. if not, I'll change it up.
    Last edited by major_small; 08-29-2005 at 10:24 PM.
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  3. #3
    Banned
    Join Date
    Jun 2005
    Posts
    594
    nope its perfect just liek that and is what i expected

  4. #4
    Banned
    Join Date
    Jun 2005
    Posts
    594
    woot not many replies, but we have the making of a real contest
    here, already got 5 submissions!!

    do me a favor guys post in here right after you submit,
    so the thread get some mroe attention and we get
    partitipants!

  5. #5
    Registered User
    Join Date
    Mar 2003
    Posts
    134
    Alright, here is my submission

    Last edited by noob2c; 08-31-2005 at 09:59 AM.

  6. #6
    Dump Truck Internet valis's Avatar
    Join Date
    Jul 2005
    Posts
    357
    I know you told us to submit the files to you, but it's somewhat late over here and I will be at school till past 3 tommorrow (sorry).

    My submission:
    Code:
    char GoldCoinCmdLine ( void )
    {
    	char	cpTmpBuf[255] ;
    
    	DWORD dwTotalDays = 0 ;
    	DWORD dwCurrentDays = 0 ;
    	DWORD dwCoins = 0 ;
    	DWORD dwPay = 1 ;
    	DWORD dwTmp = 1 ;
    
    	/* setup element 0 for _cgets */
    	cpTmpBuf[0] = 255 ;
    
    	while ( _cgets ( cpTmpBuf ) )
    	{
    		if ( cpTmpBuf[2] == '0' )
    			break ;
    
    		dwTotalDays = atoi ( cpTmpBuf + 2 ) ;
    		do
    		{
    			dwCoins += dwPay ;
    
    			/* have dwPay days elapsed? */
    			if ( !--dwTmp )
    				dwTmp = ++dwPay ;
    		} while ( ++dwCurrentDays < dwTotalDays ) ;
    
    		printf ( "%i %i\n", dwTotalDays, dwCoins ) ;
    
    		/* reset */
    		dwCurrentDays = 0 ;
    		dwCoins = 0 ;
    		dwPay = 1 ;
    		dwTmp = 1 ;
    	}
    
    	return ( 0 ) ;
    }
    Compiled under cl shipped with vs.net studio 2003
    Last edited by valis; 08-30-2005 at 11:55 PM.

  7. #7
    Registered User
    Join Date
    Aug 2005
    Posts
    91
    A "beginner's" contest? Either I'm less than a beginner, or my brain has slowed down tonight. I tried and failed to create such a program. :P
    It's Link, not linkofazeroth. The latter's just my username. The former's my online identity. Thank you.

  8. #8
    Banned
    Join Date
    Jun 2005
    Posts
    594
    keep trying id say this is fairly low level, use your brain.

  9. #9
    Registered User
    Join Date
    Aug 2005
    Posts
    91
    Like I said, my brain is slow. It's 12 midnight where I am.
    It's Link, not linkofazeroth. The latter's just my username. The former's my online identity. Thank you.

  10. #10
    Information Crocodile
    Join Date
    Dec 2004
    Posts
    204
    Why post the solutions here? Do you guys want enhanced version of your codes to compete with yours? Its unfair for those who submitted early..

  11. #11
    Banned
    Join Date
    Jun 2005
    Posts
    594
    yea my earlier post i didnt exactly mean post
    your solutions.

    i was looking mroe fo just a post that said you where
    in and that you sent yoru submission.

  12. #12
    Banned
    Join Date
    Jun 2005
    Posts
    594
    hey guys ill try and have a winner posted tonight, but
    somethign wonderful and unexpeced came up, so
    im gonna be out most the day. stay posted though
    ill be posting a new contest after i publish the winners.

  13. #13
    Banned
    Join Date
    Jun 2005
    Posts
    594
    i would like to thank everyone who participated, and i hope that
    you will continue to compete in my contests.

    first off everyone submission was decent, but everyone
    contained at least one error or bug, or didnt complete
    the assignment to what i expected.

    reguardless of that, noob2c and major_smalls
    were the last two standing.

    major_smalls ends up being the champion here
    through the 2nd rule, being number of characters long.

    i did not count whitespace or comments, just code
    characters.

    i will post his code below, if you compile his code you
    will notice you will get an error when compiling
    due to the "getline" missing the std:: . it was
    a obvious error and was easily fixed.

    thanks once again, check back in a few i should have another
    contest posted.
    Attached Files Attached Files

  14. #14
    Dump Truck Internet valis's Avatar
    Join Date
    Jul 2005
    Posts
    357
    Quote Originally Posted by loko
    Why post the solutions here? Do you guys want enhanced version of your codes to compete with yours? Its unfair for those who submitted early..
    I do apologize to the others that participated, as for myself, I don't enter contests to compete- I'm just interested in seeing what everyone comes up with and what I come up with myself.

  15. #15
    Registered User
    Join Date
    Mar 2003
    Posts
    134
    kudos to major_smalls

    here is my code anywho for anyone who wants it as reference

    Code:
    #include <iostream>
    #include <vector>
    
    using namespace std;
    
    int main()
    {
    	int userdays=1,coin=1,total_coins=0,i=0,k=0,temp=0;
    	vector<int> user_input,output;
    	
    	cout <<"Enter the number of days: ";
    	while(userdays != 0 )
    	{
    		cin >> userdays;
    		user_input.push_back(userdays);
    	}
    	
    	user_input.pop_back();
    	temp = user_input.size();
    	for(i = 0; i < temp;i++)
    	{
    		while(k < user_input[i])
    		{
    			for(int j = 0; j < coin;j++)
    			{
    				total_coins += coin;
    				k++;
    				if(k >= user_input[i])j=coin; //if k is greater than user days, quit loop
    			}
    			coin++;
    		}
    		output.push_back(total_coins); //at this point we push the total coins into the vector
    		total_coins=0; //reset the values of these vars to original
    		k=0;
    		coin=1;
    	}
    	for(int t = 0; t < temp; t++)cout<<"\nNumber of days: "<<user_input[t]<<endl<<"Number of coins at the end of those days: "<<output[t]<<"\n\n";
    	return 0;
    }

Page 1 of 2 12 LastLast
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