hey, look
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
bool contains(char *token, int size)
{
return (size >=2 && token[size-2]=='a' && token[size-1]=='b');
}
int main ()
{
int count=0;
string word;
char complete_word[11111];
char *token;
getline( cin, word );
strcpy ( complete_word, word.c_str() );
token = strtok( complete_word , " " );
while( token != NULL )
{
if ( contains( token, strlen(token)) )
count ++;
token = strtok( NULL, " " );
}
cout<< count <<endl;
}
|
Last edited on