HOLE IN THE TEXT

i using c++
what is the problem with my code it is showing wrong answer

#include<iostream>
#include<string>
using namespace std;
int holecount(char one);
int main()
{
int i,j,k;
int n,num=0;
cin>>n;

for(i=0;i<n;i++)
{
string str;
cin>>str;
for(j=0;j<str.length;j++)
{

 num+= holecount(str[j]);

}
cout<<num;
num=0;
}
return 0;
}
int holecount(char one)
{
    switch (one)
    {

        case 'A': return 1;
        break;
            case 'B': return 2;
        break;
            case 'C': return 0;
        break;
            case 'D': return 1;
        break;
            case 'E': return 0;
        break;
            case 'F': return 0;
        break;
            case 'G': return 0;
        break;
            case 'H': return 0;
        break;
            case 'I': return 0;
        break;
            case 'J': return 0;
        break;
            case 'K': return 0;
        break;
            case 'L': return 0;
        break;
            case 'M': return 0;
        break;
            case 'N': return 0;
        break;
            case 'O': return 1;
        break;
            case 'P': return 1;
        break;
            case 'Q': return 1;
        break;
            case 'R': return 1;
        break;
            case 'S': return 0;
        break;
            case 'T': return 0;
        break;
            case 'U': return 0;
        break;
            case 'V': return 0;
        break;
            case 'W': return 0;
        break;
            case 'X': return 0;
        break;
            case 'Y': return 0;
        break;
            case 'Z': return 0;
        break;
        default : return 0;
        break;
    }
}

I think your algo will be shorter if your switch statement will just check only for letters A B D O P Q R

Your code cannot be compiled, probably you lost () for length during the copy and paste operation.

Your code returns 12 for input

2
A
B

As given in output format, output of each test case must be printed on individual single line. So print a ’
’ after printing the answer for each case. Change the statement to cout<<num<<endl;

Yes, it is an improvement, but it is not a problem… Also combibation of return and break is strange.