Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "bits/stdc++.h"
- using namespace std;
- int main () {
- /*
- // 01234567
- string s = "abcdefgh";
- */
- //int n = s.size(); //size of string
- /*
- for (int i = 0; i < n; ++i) {
- cout << s[i];
- }
- */
- /*
- //char strs[6] = {'a', 'b', 'c', 'd', 'e', 'f'};
- //s = s + "abcd"; //concatination //
- //cout << s << '\n';
- s.push_back('a'); //O(1) // abcdefgha //insert
- //cout << s << '\n'; //01234567
- s.pop_back(); //erase last element // abcdefgh
- //cout << s << '\n';
- s.erase(7, 2); // starting_pos, count
- cout << s << '\n';
- */
- /*
- string s;
- //cin >> s;
- //cout << s << endl;
- //getline(cin, s);
- cout << s << endl;
- */ // 01234567
- string s = "abcdeghh";
- //string::iterator begin = s.begin();
- //string::iterator end = s.end();
- /*
- auto begin = s.begin();
- cout << *begin << endl;
- s.erase(s.begin(), s.end()); //starting iterator, ending iterator
- cout << s << endl;
- */
- /*
- int count = 0;
- int n = s.size();
- for (int i = 0; i < n; ++i) {
- if (s[i] == 'h') {
- count++;
- }
- }
- cout << count << endl;
- */
- cout << count(s.begin() + 1, s.end(), 'a'); //count => (starting iterator, ending iterator, search character)
- }
- //https://codeforces.com/problemset/problem/1146/A
- //https://codeforces.com/problemset/problem/71/A
- //https://codeforces.com/problemset/problem/112/A
- //https://codeforces.com/problemset/problem/339/A
- //https://codeforces.com/problemset/problem/281/A
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement