Advertisement
RobertDeMilo

WB1.14.1

Sep 3rd, 2023
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <map>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     map<string, int> b = { {"a",1}, {"b",2}, {"c",3} };
  10.  
  11.     int sum = 0;
  12.     string concat;
  13.     for (auto i : b)
  14.     {
  15.         concat += i.first;
  16.         sum += i.second;
  17.     }
  18.  
  19.     cout << concat << endl;
  20.     cout << sum << endl;
  21. *******************************************************************
  22.  
  23.     string a = "asdfasdfasdf";
  24.     int i = 0;
  25.  
  26.     for (auto c : a)
  27.     {
  28.         if (c == 'a')
  29.         {
  30.             cout << i << endl;
  31.         }
  32.         ++i;
  33.     }
  34. *******************************************************************
  35.     for (int i = 0; i < a.size(); ++i)
  36.     {
  37.         if (a[i] == 'a')
  38.         {
  39.             cout << i << endl;
  40.         }
  41.     }
  42.  
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement