Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string s1, s2;
- cin >> s1 >> s2;
- int n = s1.length(), m = s2.length();
- int *arr1 = new int[n];
- int *arr2 = new int[m];
- for (int i = 0; i < n; i++) {
- arr1[i] = s1[i] - 48;
- }
- for (int i = 0; i < m; i++) {
- arr2[i] = s2[i] - 48;
- }
- int i = 0; int j = 0;
- for (int k = 0; k < m + n - 1; ++k) {
- if (i < n && j < m) {
- if (arr1[i] < arr2[j]) {
- cout << arr1[i];
- ++i;
- }
- else {
- cout << arr2[j];
- ++j;
- }
- } else {
- if (i >= n && j < m) {
- while (j < m) {
- cout << arr2[j];
- ++j;
- }
- }
- if (j >= m && i < n) {
- while (i < n) {
- cout << arr1[i];
- ++i;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement