Friday 15 January 2016

Solution of URI 1914 :: Whose Turn Is It?


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 a,b;
    long long int c,d,e,f;
    char aa[201], bb[10], cc[201], dd[10], ee="PAR", ff="IMPAR";
    scanf("%d", &a);
    for(b=1; b<=a; b++)
    {
        scanf("%s %s %s %s", aa,bb,cc,dd);
        scanf("%lld%lld", &c, &d);
        e=c+d;
        if(bb[0]=='P')
        {
            if(e%2==0) printf("%s\n", aa);
            else printf("%s\n", cc);
        }
        else
        {
            if(e%2==0) printf("%s\n", cc);
            else printf("%s\n", aa);
        }
    }
    return 0;
}

4 comments:

  1. line 13 scanf("%s %s %s %s", &aa,&bb,&cc,&dd) lack "&"

    ReplyDelete
    Replies
    1. When you take string as input, its no need to use "&".

      Delete
  2. Replies
    1. After getting your comment, i submitted my solution again and it gets accepted.

      Delete

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