Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ vector merge algorithm

int n,a[100000], m , b[100000], p, c[200000];

//citire a[] cu n elemente
//citire b[] cu m elemente

int i = 0 , j = 0;
p = 0;
while(i < n && j < m)
    if(a[i] < b[j])
        c[p ++] = a[i ++];
    else
        c[p ++] = b[j ++];
while(i < n)
    c[p ++] = a[i ++];
while(j < m)
    c[p ++] = b[j ++];
Comment

PREVIOUS NEXT
Code Example
Cpp :: compile c++ program 
Cpp :: Int main ( ) { int i,n; cinn; i=n; while(i=1) { i=i+5; i=i-6; } } 
Cpp :: c++ loop 
Cpp :: cpp console progressbar 
Cpp :: racing horses codechef solution c++ 
Cpp :: 5 program code in c++ of friend function 
Cpp :: how to define global array in c++ in a scope 
Cpp :: show mouse c++ 
Cpp :: 2160. Minimum Sum of Four Digit Number After Splitting Digits leetcode solution in c++ 
Cpp :: multilevel inheritance in c++ private method 
Cpp :: pum game in c++ 
Cpp :: nested loop c++ program example 
Cpp :: The elements are store at contiguous memory locations in C++ 
Cpp :: c++ Is there still a need to provide default constructors to use STL containers 
Cpp :: c++ cin accept only numbers 
Cpp :: print all chrchetrs of a string c++ 
Cpp :: how to implement stack 
Cpp :: c++ & operator 
Cpp :: short hand if else in c++ 
Cpp :: c++ for 
Cpp :: x += c++ 
Cpp :: c++ forloop 
C :: c colourful output 
C :: plt hide axis ticks 
C :: find maximum number between 3 numbers in c 
C :: roshan kumar 
C :: multiplication table using c 
C :: cannot get / react router dom 
C :: c programming itoa() example 
C :: how to login to another user in powershell 
ADD CONTENT
Topic
Content
Source link
Name
4+3 =