Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

Holes in the text

$
0
0

What wrog with this code!

#include<iostream>
#include<cstring>
using namespace std;

int main()
{
    int counter=0,sum=0;
    int T,n;
    char string[100];
    cout<<"Number of the words: "<<endl;
    cin>>T;

    if(T<=40)
    {
        cout<<"Enter the word: "<<endl;

        do
        {
            gets(string);
            n=strlen(string);
            for(int i=0;i<n;i++)
            {
                if(string[i]=='A' || string[i]=='O' || string[i]=='D' || string[i]=='P' || string[i]=='R' || string[i]=='Q') counter++;
                if(string[i]=='B') counter+=2;
                sum+=counter;
            }
            T--;

        }while(T>=0);
        cout<<"Number of holes: "<<sum<<endl;


    }
    else
        cout<<"You enter wrong number!"<<endl;

    return 0;
}

Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>