Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void afisare(int *vec, int n){
  6.  
  7. if(n == 1){
  8.  
  9.  if(vec[0] < 0)
  10.  
  11.   cout << vec[0] << ' ';
  12.  
  13.  return;
  14.  
  15. }
  16.  
  17. int np2 = n / 2;
  18.  
  19. afisare(vec, np2);
  20.  
  21. afisare(vec+np2, n - np2);
  22.  
  23. }
  24.  
  25. int vect[1000];
  26.  
  27. int main(){
  28.  
  29. int n;
  30.  
  31. cin >> n;
  32.  
  33. for(int i = 0; i < n; i++) cin >> vect[i];
  34.  
  35. afisare(vect, n);
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement