#include<stdio.h> #include<math.h> void main() { char str[1000001],c; int i,T,x,word,wrong,j,l; scanf("%d",&T); for(j=1;j<=T;j++) { gets(str); i=0; x=0; wrong=0; while((c=str[i])!='\0') { if(c=='C') { if(str[i+1]=='F'&&str[i+2]=='F') x++; else if(str[i+1]!='F'||str[i+2]!='F') { wrong++; break; } } i++; } if(wrong) printf("Case #%d: -1\n",j); else printf("Case #%d: %d\n",j,x); } } |
Double click to view unformatted code.