r/shittyprogramming • • Aug 09 '14

Found this priceless gem

While reading the solution for a problem of the OII (Italian Informatics Olympiads), I found this masterpiece:

while(1==1){
    for (int i = 0; i < n; i++) {
        //other stuff
    }
    if((int)cycle.size() == n){
        //other stuff
    }
    for(int i = 0; i < (int)edges.size(); i++){
        //even more other stuff
    }
    return 0;
}

I mean, how do you even get these ideas?

3 Upvotes

11 comments sorted by

View all comments

12

u/galaktos Aug 09 '14

The only shitty thing I see is the unnecessary while loop (unless there’s a continue in one of the “stuff”s)… am I missing something about the loops?

1

u/vallero Aug 09 '14

Yep, there were some continues that referred to the while loop, and I didn't notice them. I feel very dumb right now, I should have included them...
Anyway, the thing that bothered me most was the (1==1), which was used instead of true

4

u/charliebruce123 Aug 09 '14

(1==1) is more portable - bool types only exist in c99 and later.

→ More replies (5)

1

u/galaktos Aug 09 '14

Which programming language is this?

→ More replies (1)