Advertisement
DobriyKrot

Untitled

Aug 8th, 2022
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     char ch1 = 'A';
  6.     char ch2 = 'Z';
  7.     cout << ch1 << ' ' << ch2 << '\n';
  8.     cout << (int)ch1 << ' ' << (int)ch2 << '\n';
  9.     cout << ch2 - ch1 << '\n';
  10.     char x = '9';
  11.     int y = x - '0';
  12.     cout << y << '\n';
  13.  
  14.     string s = "yes";
  15.     cout << s[0] << ' ' << s[1] << ' ' << s[2] << '\n';
  16.     s[1] = 'o';
  17.     cout << s << '\n';
  18.  
  19.     for (int i = 0; i < s.length(); ++i) {
  20.         s[i] = 'a';
  21.     }
  22.     cout << s << '\n';
  23.  
  24.     string t;
  25.     cout << t << '\n';
  26.  
  27.     string s1 = "ab";
  28.     string s2 = "cd";
  29.     cout << s1 + s2 << '\n'; // Конкатенация строк.
  30.     s1 += s2;
  31.     cout << s1 << '\n'; // abcd
  32.     cout << s1.substr(2, 2) << '\n';
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement