1 / 5
Nov 2016

Now I compile it in my computer it works fine and even in the results of the CPTTRN 1 judge thing it shows exactly the same thing in expected result and your result then why does it keep saying wrong answer ?????? what is this I cant figure it out

include

int main(void) {
int t,f;
unsigned int line,col;
int i,j,flag,isEven;
scanf("%d",&t);
for(f=1;f<=t;f++){
scanf("%u",&line);
scanf("%u",&col);

      if(line == col)
    isEven = 1;
else
    isEven = 0;
flag=0;
for(i=0;i<line;i++){
    for(j=0;j<col;j++){
        if(flag == 0){
            printf("*");
            flag = 1;
        }
        else{
            printf(".");
            flag = 0;
        }
    }

    printf("\n");
    if(isEven == 1){
        if(flag == 0)
            flag =1;
        else
            flag =0;
    }

}
printf("\n");
}
return 0;

}

  • created

    Nov '16
  • last reply

    Aug '17
  • 4

    replies

  • 814

    views

  • 3

    users

Your Code reads the number of Test cases But does not Loop over the cases

What nooo , It runs perfectly fine please try and run it ...I even get the correct output like I said but for somereason the jude says wrong answer I dont know why

oops, i missed that line, you're right.

So you might want to try this

3
3 2
3 14
2 3
9 months later

Good code. There's a little error at the end, in " return 0; ". Here I correctet some little errors.

void setup () {
int main(void);
int t,f;
unsigned int line,col;
int i,j,flag,isEven;
scanf("%d",&t);
for(f=1;f<=t;f++){
scanf("%u",&line);
scanf("%u",&col);

  if(line == col)
isEven = 1;

else
isEven = 0;
flag=0;
for(i=0;i<line;i++){
for(j=0;j<col;j++){
if(flag == 0){
printf("*");
flag = 1;
}
else{
printf(".");
flag = 0;
}
}

printf("\n");
if(isEven == 1){
    if(flag == 0)
        flag =1;
    else
        flag =0;
}

}
printf("\n");
}

}

return 0;

Suggested Topics

Topic Category Replies Views Activity
C and C++ 0 50 Jun 29

Want to read more? Browse other topics in C and C++ or view latest topics.