Saturday, May 18, 2013

SPOJ Problem TEST


Life, the Universe, and Everything

Explanation:

The problem is self-explanatory. Run an infinite loop, read the numbers and keep on printing them until you get a 42.

Solution (C++):

#include<cstdio>

int main(){
    int n;
    while(1){
        scanf("%d", &n);
        if(n==42)
            break;
        printf("%d\n", n);
    }
    return 0;
}

Any suggestions are welcome.

No comments:

Post a Comment

SPOJ Problem ONEZERO

Ones and zeros Explanation: A very good problem to practice BFS skills. I think that much hint is good to give the problem a shot. An...