m96ashu
1
#include<stdio.h>
int main()
{
int n;
scanf("%d",&n);
char a[100];
while(n–){
scanf("%s",a);
int i=0;
int count = 0;
while(a[i] != '\0')
{
if(a[i]=='A' || a[i]=='D'|| a[i]=='O'|| a[i]=='P' || a[i]=='R'){
count++;
}
else if(a[i]=='B'){
count= count+2;
}
i++;
}
printf("%d\n",count);
}
return 0;
}
take
if((a[i]==‘A’) || (a[i]==‘D’)|| (a[i]==‘O’)|| (a[i]==‘P’) || (a[i]==‘R’)||(a[i]==‘Q’))
Refer to this code.
#include <iostream>
#include <string>
using namespace std;
int main()
{
int n, yes, i,m,u;
string str;
char hole[] = {'A', 'D', 'O', 'P', 'Q', 'R'};
std::ios_base::sync_with_stdio(false);
cin>>n;
while(n--)
{
yes = 0;
cin>>str;
for (i=0; i<str.length(); i++)
{
char f=str.at(i);
for(u=0; u<6; u++)
{
if(f==hole[u])
{
yes++;
}
}
if (f=='B')
{
yes += 2;
}
}
cout<<yes<<endl;
}
}