Advertisement
Josif_tepe

Untitled

Jan 24th, 2025
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. int main() {
  6.   int n;
  7.    cin>>n;
  8.    int a[n];
  9.    for(int i=0;i<n;i++) {
  10.        cin>>a[i];
  11.    }
  12. int nova[n];
  13.    int indx=1;
  14.    nova[0]=a[0];
  15.    for (int i=1;i<n;i++) {
  16. if(a[i]>nova[indx-1]) {
  17.     nova[indx]=a[i];
  18.     indx++;
  19. }
  20.  
  21.  
  22.  
  23.  
  24.    }
  25.  
  26.  
  27.  
  28.  
  29. for(int i=0;i<indx;i++) {
  30.    cout<<nova[i]<<" ";
  31. }
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.    return 0;
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement