🟢 Վարժություն 15

Զանգվածի էլեմենտը կանվանենք «առաջնորդ», եթե այն մեծ է իրենից աջ գտնվող բոլոր էլեմենտներից։ Ամենավերջին էլեմենտը միշտ համարվում է առաջնորդ։ Գրեք ծրագիր, որը մուտքում ստանում է ամբողջ թվերի զանգված և էկրանին տպում է բոլոր «առաջնորդ» էլեմենտները։
 
#include <iostream>
void printLeaders(int arr[], const int N) {
   // Put code to print array leaders
}
int main() {
	const int N = 7;
  int arr[N] = {};
  std::cout << "Input " << N << " size array: ";
  for (int i = 0; i < N; i++) {
     int in;
     std::cin >> in;
     arr[i] = in; 
     std::cout << arr[i] << " ";
  }
  std::cout << std::endl;
  // Put your code here
}
 
 

Constraints

Time limit: 0.2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue