Advertisement
smatskevich

Lesson14

Mar 4th, 2023
696
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.14 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <tuple>
  4.  
  5. using namespace std;
  6.  
  7. int main0() {
  8.   auto p = make_pair(1, 3);
  9.   cout << p.first << " " << p.second << endl;
  10.  
  11.   auto [a, b] = make_pair(1, 3);
  12.   cout << a << " " << b << endl;
  13.  
  14.   int c = 0, d = 0;
  15.   tie(c, d) = make_pair(1, 3);
  16.   cout << c << " " << d << endl;
  17.  
  18.   pair<int, int> p2{1, 3};  // = {1, 3};
  19.   cout << p2.first << " " << p2.second << endl;
  20.   return 0;
  21. }
  22.  
  23. int main1() {
  24.   string s;
  25.   cin >> s;
  26.   cout << s << endl;
  27.   cout << s.length() << " " << s.size() << endl;
  28.   for (char c : s) cout << c << " ";
  29.   cout << endl;
  30.   return 0;
  31. }
  32.  
  33. int main3() {
  34.   char c = '1';
  35.   cout << c << endl;
  36.   int i = c - '0';
  37.   cout << i << endl;
  38.   return 0;
  39. }
  40.  
  41. int main4() {
  42.   string s = "lnip123456";
  43.   s.erase(2, 3);
  44.   cout << s << endl;
  45.   s.append(" Hello");
  46.   cout << s << endl;
  47.   s.insert(7, "789");
  48.   cout << s << endl;
  49.   s.replace(7, 4, "#########");
  50.   cout << s << endl;
  51.   string t = s.substr(4, 5);
  52.   cout << t << endl;
  53.   return 0;
  54. }
  55.  
  56. int main() {
  57.   string s; cin >> s;
  58.   string t = s;
  59.   reverse(t.begin(), t.end());
  60.   cout << s + t << endl;
  61.   return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement