![]() |
| | #1 |
| Banned Join Date: Jun 2005
Posts: 594
| New Contest C & C++ Welcome 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. |
| ILoveVectors is offline | |
| | #2 |
| Registered User 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
__________________ 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 Last edited by major_small; 08-29-2005 at 10:24 PM. |
| major_small is offline | |
| | #3 |
| Banned Join Date: Jun 2005
Posts: 594
| nope its perfect just liek that and is what i expected |
| ILoveVectors is offline | |
| | #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! |
| ILoveVectors is offline | |
| | #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. |
| noob2c is offline | |
| | #6 |
| Dump Truck Internet 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 ) ;
}
Last edited by valis; 08-30-2005 at 11:55 PM. |
| valis is offline | |
| | #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. |
| linkofazeroth is offline | |
| | #8 |
| Banned Join Date: Jun 2005
Posts: 594
| keep trying id say this is fairly low level, use your brain. |
| ILoveVectors is offline | |
| | #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. |
| linkofazeroth is offline | |
| | #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.. |
| loko is offline | |
| | #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. |
| ILoveVectors is offline | |
| | #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. |
| ILoveVectors is offline | |
| | #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. |
| ILoveVectors is offline | |
| | #14 | |
| Dump Truck Internet Join Date: Jul 2005
Posts: 357
| Quote:
| |
| valis is offline | |
| | #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;
}
|
| noob2c is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Expression Evaluator Contest | Stack Overflow | Contests Board | 20 | 03-29-2005 10:34 AM |
| Obfuscated Code Contest | Stack Overflow | Contests Board | 51 | 01-21-2005 04:17 PM |
| WANTED: Contest Master | kermi3 | A Brief History of Cprogramming.com | 15 | 01-23-2003 10:15 PM |