Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <map>
- #include <string>
- using namespace std;
- int main()
- {
- map<string, int> b = { {"a",1}, {"b",2}, {"c",3} };
- int sum = 0;
- string concat;
- for (auto i : b)
- {
- concat += i.first;
- sum += i.second;
- }
- cout << concat << endl;
- cout << sum << endl;
- *******************************************************************
- string a = "asdfasdfasdf";
- int i = 0;
- for (auto c : a)
- {
- if (c == 'a')
- {
- cout << i << endl;
- }
- ++i;
- }
- *******************************************************************
- for (int i = 0; i < a.size(); ++i)
- {
- if (a[i] == 'a')
- {
- cout << i << endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement