int
#include <stdio.h>
#include <string.h>
int main()
{
int nCase=0;
char Buffer[10][100];
memset(Buffer,0,sizeof(Buffer));
printf("Enter The number of STring to Test ");
scanf("%d",&nCase);
printf("Entered The number of STring to Test %d ",nCase);
if((nCase>=1)&&(nCase<=10))
{
for(int i=0;i<nCase;i++)
{
printf("\nenter string -> ");
scanf("%s",&Buffer[i][0]);
}
for(int i=0;i<nCase;i++)
{
int ncount=-1;
for(int j=0;j+2<100;j++)
{
if((Buffer[i][j]=='g')&&(Buffer[i][j+1]=='f')&&(Buffer[i][j+2]=='g'))
{
ncount++;
}
}
if(ncount!=-1)
{
printf("%d\n",ncount+1);
}
else
{
printf("-1\n");
}
}
}
else
{
printf(" \n Invalid Test Case Number");
}
printf(" \n **** test case finished*** ");
}
No comments:
Post a Comment