Programming contest #3

Posts 1–13 of 13 · Page 1 of 1
Programming contest #3
Coders Lounge - MPGH - MultiPlayer Game Hacking

Could someone explain to me why this is failing?
haven't coded in a long time.
I know I still need to add the 29 of Feb once in 4 years.
Code:
#include <iostream>
using namespace std;

int main()
{
    int days[12]={31,28,31,30,31,30,31,31,30,31,30,31};

    int noobcake=5;
    int total=0;
    int years=0;
    
    
    for(;years++;years!=100)
    {
                            cout<<years<<"this is never executed";
    for(int month=0;month++;month!=12)
    {
    if(noobcake==6)total=total+1;
                         
    noobcake=(noobcake+days[month])%7;
    cout<<month;
    }
                         
    }
    
    cout<<total;
    system("pause");
    return 0;
}
if (years % 4 == 0)
// its a leap year ! O:
Quote Originally Posted by Toxic Waltz View Post
I know I still need to add the 29 of Feb once in 4 years.
The message you have entered is too short. Please lengthen your message to at least 10 characters
Can someone please take a look at this and explain it to me?
I don't bother looking at that kind of indented code. sry
Take a look at the contest thread, the solutions were posted there. use them to see what went wrong ^^
I don't know what makes me more sad.

Me making an error in the for loop or this forum not correcting me on a little mistake.
Quote Originally Posted by Toxic Waltz View Post
I don't know what makes me more sad.

Me making an error in the for loop or this forum not correcting me on a little mistake.
I didnt even look at the code. When i see:

............................for here
........if here
for here
if here

i just ignore
Quote Originally Posted by 'Bruno View Post
I didnt even look at the code. When i see:

............................for here
........if here
for here
if here

i just ignore
Code:
#include <iostream>
using namespace std;

int main()
{
    int days[12]={31,28,31,30,31,30,31,31,30,31,30,31};

    int noobcake=5;
    int total=0;
     
    for(int years =1900;years<2000;years++)
    {
                            cout<<years<<" ";
                            for(int month=0;month<12;month++)
                            {
            
                                    if(noobcake==6)total++;
                                    if(month==2)
                                    {
                                                if(!(years%4))noobcake++;
                                    }
                                                
                         
                                    noobcake=(noobcake+days[month])%7;
    
                            }
                         
    }
    
    cout<<total;
    system("pause");
    return 0;
}
<3
Quote Originally Posted by Toxic Waltz View Post
Code:
#include <iostream>
using namespace std;

int main()
{
    int days[12]={31,28,31,30,31,30,31,31,30,31,30,31};

    int noobcake=5;
    int total=0;
     
    for(int years =1900;years<2000;years++)
    {
                            cout<<years<<" ";
                            for(int month=0;month<12;month++)
                            {
            
                                    if(noobcake==6)total++;
                                    if(month==2)
                                    {
                                                if(!(years%4))noobcake++;
                                    }
                                                
                         
                                    noobcake=(noobcake+days[month])%7;
    
                            }
                         
    }
    
    cout<<total;
    system("pause");
    return 0;
}
<3
see... thats something decent <3
0.02 ms just like mine after removing the cout<<years<<" ";
I guess i lost some time on that switch case tho.. meh lol

gratz toxic
Posts 1–13 of 13 · Page 1 of 1

Post a Reply

Tags for this Thread

None

Need help?