Advertisement
StoneHaos

920

Nov 2nd, 2019
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. //920
  2. #include <cstdio>
  3.  
  4. char s[101];
  5. int n;
  6.  
  7. int main(void) {
  8.     FILE* fin = fopen("input.txt", "r");
  9.     FILE* fout = fopen("output.txt", "w");
  10.  
  11.     fscanf(fin, "%d%s", &n, s);
  12.     fclose(fin);
  13.     int x = 0, out = 0;
  14.     for (int i = 0; i < n; ++ i) {
  15.         if (s[i] == 'x')
  16.             ++ x;
  17.         else if (x > 2) {
  18.             out += x - 2;
  19.             x = 0;
  20.         }
  21.         else
  22.             x = 0;
  23.     }
  24.     if (x > 2)
  25.         out += x - 2;
  26.  
  27.     fprintf(fout, "%d\n", out);
  28.     fclose(fout);
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement