Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

Why is my answer wrong for The Guessing Game (Easy)?

$
0
0

include <stdio.h>

include <string.h>

int main(int argc, const char * argv[]) { int j,t;

scanf("%d",&t);
for(j=0;j<t;j++) {
int k,i,truth=0,lie;


char str[90];
char a;
int b,n;

    scanf("%d",&n);




scanf("%d\n",&k);




for(i=0;i<k;i++) {
scanf("\n%c %d %s",&a,&b,str);
    int y=strcmp(str,"Yes");
    int x=strcmp(str,"No");
    if(a=='<') {
        if(n<b&&y==0){
            truth++;

        }
        else if(n>b&&x==0) {
            truth++;
        }
        else if(n==b&&x==0) {
            truth++;
        }
    }
    else if(a=='>') {
        if(n>b&&y==0){
            truth++;

        }
        else if(n<b&&x==0) {
            truth++;
        }
        else if(n==b&&x==0) {
            truth++;
        }

    }
        else if(a=='=') {
            if(n==b&&y==0){
                truth++;

            }
            else if(n<b&&x==0) {
                truth++;
            }
            else if(n>b&&x==0) {
                truth++;
            }






    }


}
printf(" %d\n",lie=k-truth);
}
return 0;

}


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>