You are not logged in. Please login at www.codechef.com to post your questions!

×

Holes in Text Wrong Answer

I am using the below code to solve the HOLES in the TEXT problem, I am getting the expected o/p, but Its is not accepting the answer, I have checked the other solutions also they have the same logic as mine, But I don't know why my solution is not being accepted.

Please help me out here

This is my code which i have used

#include<stdio.h>
int main(void)
{
    int test;
    scanf("%d",&test);
    while(test--)
    {   
        char str[100];
        int holes=0;
        scanf("%s",str);
          int i;
        for(i=0;str[i]!='\0';++i)
                {
                           if(str[i]=='A'||str[i]=='D'||str[i]=='O'||str[i]=='P'||str[i]=='R'||str[i]=='Q')
                ++holes;
            if(str[i]=='B')
               holes=holes+2;
        }
        printf("%d",holes);
    }
}

asked 24 Mar '15, 17:13

rohitsaluja's gravatar image

0★rohitsaluja
512
accept rate: 0%


You need to print each output ( number of holes ) at a new line.

Change the line printf("%d",holes); to printf("%d\n",holes); and it will be accepted.

Check your accepted code with the above modification here.

link

answered 24 Mar '15, 17:21

mediocoder's gravatar image

3★mediocoder
1.1k313
accept rate: 36%

edited 24 Mar '15, 17:23

Thanks, feeling embarrassed I should be more careful before posting.

(24 Mar '15, 17:26) rohitsaluja0★

Don't worry, small points like these sometimes get overlooked.
We all make silly mistakes quite often, this makes us human.

(24 Mar '15, 17:33) mediocoder3★
toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×1,488
×354
×191

question asked: 24 Mar '15, 17:13

question was seen: 541 times

last updated: 24 Mar '15, 17:33