Promi_38

cf 801A

Jan 12th, 2021
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3.  
  4. int main()
  5. {
  6.     char s[110];
  7.     scanf("%s", s);
  8.    
  9.     int i;
  10.     int cnt = 0;
  11.     for(i = 0; i < strlen(s); i++)
  12.     {
  13.         if(s[i] == 'V' && s[i+1] == 'K')
  14.         {
  15.             s[i] = '#';
  16.             s[i+1] = '#';
  17.             cnt++;
  18.         }
  19.     }
  20.    
  21.     for(i = 0; i < strlen(s); i++)
  22.     {
  23.         if((s[i] == 'V' && s[i+1] == 'V') || (s[i] == 'K' && s[i+1] == 'K'))
  24.         {
  25.             s[i] = 'V';
  26.             s[i+1] = 'K';
  27.             cnt++;
  28.             break;
  29.         }
  30.     }
  31.     //for(i = 0; i < strlen(s); i++) printf("%c", s[i]);
  32.    
  33.     printf("%d\n", cnt);
  34. }
Advertisement
Add Comment
Please, Sign In to add comment