Advertisement
newb_ie

Untitled

Apr 23rd, 2022
496
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. #include "bits/stdc++.h"
  2.  
  3. using namespace std;
  4.  
  5. int main () {
  6. /*
  7. // 01234567
  8. string s = "abcdefgh";
  9. */
  10. //int n = s.size(); //size of string
  11. /*
  12. for (int i = 0; i < n; ++i) {
  13. cout << s[i];
  14. }
  15. */
  16. /*
  17. //char strs[6] = {'a', 'b', 'c', 'd', 'e', 'f'};
  18. //s = s + "abcd"; //concatination //
  19. //cout << s << '\n';
  20. s.push_back('a'); //O(1) // abcdefgha //insert
  21. //cout << s << '\n'; //01234567
  22. s.pop_back(); //erase last element // abcdefgh
  23. //cout << s << '\n';
  24. s.erase(7, 2); // starting_pos, count
  25. cout << s << '\n';
  26. */
  27. /*
  28. string s;
  29. //cin >> s;
  30. //cout << s << endl;
  31. //getline(cin, s);
  32. cout << s << endl;
  33. */ // 01234567
  34. string s = "abcdeghh";
  35.  
  36. //string::iterator begin = s.begin();
  37. //string::iterator end = s.end();
  38. /*
  39. auto begin = s.begin();
  40. cout << *begin << endl;
  41. s.erase(s.begin(), s.end()); //starting iterator, ending iterator
  42. cout << s << endl;
  43. */
  44. /*
  45. int count = 0;
  46. int n = s.size();
  47. for (int i = 0; i < n; ++i) {
  48. if (s[i] == 'h') {
  49. count++;
  50. }
  51. }
  52. cout << count << endl;
  53. */
  54. cout << count(s.begin() + 1, s.end(), 'a'); //count => (starting iterator, ending iterator, search character)
  55. }
  56.  
  57. //https://codeforces.com/problemset/problem/1146/A
  58. //https://codeforces.com/problemset/problem/71/A
  59. //https://codeforces.com/problemset/problem/112/A
  60. //https://codeforces.com/problemset/problem/339/A
  61. //https://codeforces.com/problemset/problem/281/A
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement