Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. bool cek(char a) {
  6. if (int(a) >= 97 && int(a) <= 122) return false;
  7. return true;
  8. }
  9.  
  10. int main() {
  11. int n, hitung = 0;
  12. string kata, temp, test;
  13.  
  14. cin >> n;
  15.  
  16. getline(cin, test);
  17. getline(cin, kata);
  18.  
  19. char a,b,c;
  20. a = kata[0];
  21. b = kata[1];
  22. c = kata[2];
  23.  
  24. for (int i=3;i<=n;i++) {
  25. if (a == 'h' && b == 'h' && c == 'h') {
  26. hitung++;
  27. }
  28.  
  29. if (cek(a) || cek(b) || cek(c)) {
  30. n = -1;
  31. break;
  32. }
  33.  
  34. a = kata[i-2];
  35. b = kata[i-1];
  36. c = kata[i];
  37. }
  38.  
  39. if (n == kata.length()) cout << hitung << endl;
  40. else if (n < 3 || n > 100) cout << 0 << endl;
  41. else cout << 0 << endl;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement