Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- char ara[100000];
- int main()
- {
- int T;
- scanf("%d",&T);
- while (T--) {
- scanf("%s", ara);
- int length = strlen(ara);
- int i,cnt = 0,caseno =1;
- while (1) {
- int sum = 0;
- for (i=0;i<length;i++) {
- if (ara[i] == 'W') {
- sum++;
- ara[i] = '\0';
- break;
- }
- }
- for (;i<length;i++) {
- if (ara[i] == 'O') {
- sum++;
- ara[i] = '\0';
- break;
- }
- }
- for (;i<length;i++) {
- if (ara[i] == 'W') {
- sum++;
- ara[i] = '\0';
- break;
- }
- }
- if (sum == 3) {
- cnt++;
- }
- else {
- break;
- }
- }
- printf("Case %d: %d\n",caseno,cnt);
- caseno++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment