immuntasir

SUB2015-B

Feb 8th, 2015
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.06 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. char ara[100000];
  5. int main()
  6. {
  7.     int T;
  8.     scanf("%d",&T);
  9.     while (T--) {
  10.         scanf("%s", ara);
  11.         int length = strlen(ara);
  12.         int i,cnt = 0,caseno =1;
  13.         while (1) {
  14.             int sum = 0;
  15.             for (i=0;i<length;i++) {
  16.                 if (ara[i] == 'W') {
  17.                 sum++;
  18.                 ara[i] = '\0';
  19.                 break;
  20.                 }
  21.             }
  22.  
  23.             for (;i<length;i++) {
  24.                 if (ara[i] == 'O') {
  25.                     sum++;
  26.                     ara[i] = '\0';
  27.                     break;
  28.                 }
  29.             }
  30.  
  31.             for (;i<length;i++) {
  32.                 if (ara[i] == 'W') {
  33.                 sum++;
  34.                 ara[i] = '\0';
  35.                 break;
  36.                 }
  37.             }
  38.  
  39.             if (sum == 3) {
  40.                 cnt++;
  41.             }
  42.             else {
  43.                 break;
  44.             }
  45.  
  46.         }
  47.         printf("Case %d: %d\n",caseno,cnt);
  48.         caseno++;
  49.     }
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment