Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <clocale>
- using namespace std;
- int main(){
- setlocale(LC_CTYPE, "rus");
- int N=7, M=6, step, i=0, j=0;
- int A[N] = {2, 7, 8, 11, 15, 20, 30}; // i
- int B[M] = {1, 9, 16, 21, 25, 40}; // j
- int C[M+N];
- for (step = M+N-1; step >= 0; step--){
- if (((A[i] < B[j]) && (i < N)) || (j > M)){
- C[step] = A[i];
- i++;
- }
- else{
- C[step] = B[j];
- j++;
- }
- }
- for (i = 0; i < M+N; i++) cout<<C[i]<<" ";
- return 0;
- }
Add Comment
Please, Sign In to add comment