Quick actions

cmd+k|ctrl+k

Navigation

Languages

lab6 - 157

Snippet info

Language

Cpp

Visibility

public

Author

maloy-

Created

2018-11-11T18:03:31Z

Updated

2018-11-11T18:03:31Z

#include <iostream>
using namespace std;

int main() {    
    int x , y ; 
    int a[100] , b[100] , c[100] ;
    int i , j , k  , m ;
    cin >> x >> y ; 
    for ( int i = 0; i<=x ; i++){
        cin >> a[i];
    }
    for ( int j = 0; j<=y ; j++){
        cin >> b[j];
    }
    i = 1; 
    j = 1; 
    k = 1; 
    while ((i <= x) and (j <= y)) {
        if ((i<=x) and (j<=y)){
            if (a[i]<b[j]){
                c[k] = a[i];
                i++;
                k++;
            }
            else{
                c[k] = b[j];
                j++;
                k++;
            }
        }
        else if (j>y){
            c[k] = b[j];
            j++;
            k++;
        }
        
        
        
    }
    
    
    for (int i =0; i<=(x+y);i++){
        cout << c[i] << endl ; 
    }
    
    
    
  
    return 0;
}
INFO