Anik_Akash

ans 1- merge array

Oct 6th, 2021 (edited)
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.12 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace    std;
  3.  
  4. #define flush                    cin.ignore(numeric_limits<streamsize>::max(),'\n')
  5. #define FASTERIO                 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
  6. #define NL                       cout<<'\n';
  7. #define pi                       acos(-1.0) //3.1415926535897932384626
  8. #define pb                       push_back
  9. #define mk                       make_pair
  10. #define mx                       1000005
  11. #define EPS                      1e-10
  12. #define dpoint(x)                fixed<<setprecision(x)
  13. typedef long long int            ll;
  14. typedef double                   dl;
  15. typedef unsigned long long int   ull;
  16.  
  17. //Funtions
  18. template <class T> T digitsum(T n) {T sum = 0; while (n != 0) {sum += n % 10; n /= 10;} return sum;}
  19. int gcd(int a, int b) { int x ; return x = __gcd(a, b);}
  20. int lcm(int a, int b) {int y; return y = ((a) * ((b) / gcd(a, b)));}
  21.  
  22. // Debugger
  23. #define gobug                   0
  24. #define debugNS(a,b,c)          cout<<a<<b<<c<<endl;
  25. #define debugN(b)               cout<<b<<endl;
  26.  
  27. int ROW[] = { +0, +0, -1, +1};
  28. int COL[] = { +1, -1, +0, +0};
  29.  
  30. int X[] = { +0, +0, +1, -1, -1, +1, -1, +1}; // Kings Move
  31. int Y[] = { -1, +1, +0, +0, +1, +1, -1, -1}; // Kings Move
  32.  
  33. int KX[] = { -2, -2, -1, -1,  1,  1,  2,  2}; // Knights Move
  34. int KY[] = { -1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
  35.  
  36.  
  37. void sort_ascending(int arr[], int n){
  38.     for(int i=0; i<n-1; i++){
  39.         for(int j=i+1; j<n; j++){
  40.             if(arr[i]>arr[j])swap(arr[i],arr[j]);
  41.         }
  42.     }
  43. }
  44.  
  45. int main() {
  46.  
  47. #ifdef anikakash
  48.     clock_t tStart = clock();
  49.     freopen("input.txt", "r", stdin);
  50.     freopen("output.txt", "w", stdout);
  51. #endif
  52.  
  53.     FASTERIO; //cmt when use scanf & printf ;
  54.  
  55.     int arr[1005];
  56.     int n; cin>>n;
  57.     for(int i=0; i<n; i++)cin>>arr[i];
  58.     int tt; cin>>tt;
  59.     tt+=n;
  60.     for(int i=n; i<tt; i++)cin>>arr[i];
  61.  
  62.         sort_ascending(arr,tt);
  63.     for(int i=0; i<tt; i++)
  64.         cout<<arr[i]<<" ";
  65.  
  66.  
  67. #ifdef anikakash
  68.     fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
  69. #endif
  70.  
  71.     return 0;
  72. }
Add Comment
Please, Sign In to add comment