SHARE
TWEET

Câu 4: Viết 1 hàm kết hợp 2 dãy bằng cách xen kẽ các phần tử

a guest Feb 21st, 2020 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3. void fusion(char A[], int n, char B[], int m)
  4. {
  5.     char C[100];
  6.     int j = 0;
  7.     for (int i = 0; i < n; i++)
  8.     {
  9.         C[j] = A[i];
  10.         C[j + 1] = B[i];
  11.         j = j + 2;
  12.     }
  13.     for (int i = 0; i < n + m; i++)
  14.     {
  15.         cout << C[i] << " ";
  16.     }
  17. }
  18. int main()
  19. {
  20.     char A[5] = {'a', 'b', 'c', 'd', 'e'};
  21.     char B[5] = {'1', '2', '3', '4', '5'};
  22.     fusion(A, 5, B, 5);
  23.     return 0;
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top