fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main() {
  6. vector <int> A ={-4,3};
  7. vector <int> B ={-2,-2};
  8. vector <int> C;
  9. int m=A.size();
  10. int n=B.size();
  11. C.resize(m+n);
  12. int i=0;
  13. int j=0;
  14. int p=0;
  15. while(i<m && j<n){
  16. if(A[i]<B[j]){
  17. C[p]=A[i];
  18. cout<<p<<" "<<i<<" "<<j<<" "<<C[p-1]<<endl;
  19. p++;
  20. i++;
  21. cout<<p<<" "<<i<<" "<<j<<" "<<C[p-1]<<endl;
  22. }
  23. else{
  24. C[p]=B[j];
  25. cout<<p<<" "<<i<<" "<<j<<" "<<C[p-1]<<endl;
  26. p++;
  27. j++;
  28. cout<<p<<" "<<i<<" "<<j<<" "<<C[p-1]<<endl;
  29. }
  30. }
  31. A.resize(m+n);
  32. for(int l=0;l<m+n;l++){
  33. A[l]=C[l];
  34. cout<<A[l]<<endl;
  35. }
  36. }
Success #stdin #stdout 0s 4400KB
stdin
Standard input is empty
stdout
0 0 0 0
1 1 0 -4
1 1 0 -4
2 1 1 -2
2 1 1 -2
3 1 2 -2
-4
-2
-2
0