Tuesday, 29 March 2016

Solution of URI 2031 :: Rock, Paper, Airstrike


Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.

/**Bismillahir Rahmanir Rahim.**/

#include <stdio.h>
#include <string.h>
int main()
{
    int tst;
    char f[10], s[10];
    scanf("%d", &tst);
    while(tst--)
    {
        scanf("%s", f);
        scanf("%s", s);
        if(f[1]=='e' && s[1]=='e') printf("Sem ganhador\n");
        else if(f[1]=='t' && s[1]=='t') printf("Aniquilacao mutua\n");
        else if(f[1]=='a' && s[1]=='a') printf("Ambos venceram\n");
        else if(f[1]=='t' || (f[1]=='e' && s[1]=='a'))
            printf("Jogador 1 venceu\n");
        else printf("Jogador 2 venceu\n");
    }
    return 0;
}

2 comments:

  1. Thanks for teaching me two things: even simpler usage of while structure and avoiding same char comparisons.

    ReplyDelete

Note: only a member of this blog may post a comment.