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

×

HOLES ,GETTING WRONG ANSWER

#include<stdio.h>
#include<string.h>
 int main()
  {
    int t,i,J,c;
    char a[101],n=0;
    scanf("%d",&t);
    for(i=0;i<t;i++)
     {   
     scanf("%s",a);
     c=strlen(a);
     J=0;
     n=0;
     for(J=0;J<c;J++)
     {
          if(a[J]=='A'||a[J]=='D'||a[J]=='O'||a[J]=='P'||a[J]=='Q'||a[J]=='R')
          {
               n=n+1; 
          }
          else

        if(a[J]=='B')
            {   
                     n=n+2;
            }   
     }

    printf("%d\n",n);}


//      getch();
        return 0;
    }

asked 03 Apr '14, 07:27

sarique's gravatar image

1★sarique
-1119
accept rate: 0%

edited 03 Apr '14, 09:38

vermashubhang's gravatar image

5★vermashubhang
1.5k11025


The only error in the solution is that you have taken the data type of variable n to be a Character. Change it to Integer and it would get accepted.

link

answered 03 Apr '14, 09:47

vermashubhang's gravatar image

5★vermashubhang
1.5k11025
accept rate: 23%

thanks u very much

(04 Apr '14, 07:52) sarique1★
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:

×856
×1

question asked: 03 Apr '14, 07:27

question was seen: 520 times

last updated: 04 Apr '14, 07:52