mirea-projects/First term/Algorithms/extra/5.cpp

34 lines
723 B
C++
Raw Permalink Normal View History

2024-09-23 23:22:33 +00:00
#include <ctime>
#include <iostream>
using namespace std;
int main() {
srand(time(0));
int arraySize = rand() % 50;
int *numbers = new int[arraySize];
cout << "[ ";
for (int index = 0; index < arraySize; ++index) {
numbers[index] = rand() % 10;
cout << numbers[index] << " ";
}
cout << "] (" << arraySize << ")" << endl;
bool isDescending = true;
int previousNumber = numbers[0];
for (int index = 0; index < arraySize; ++index) {
if (numbers[index] >= previousNumber) {
isDescending = false;
break;
}
previousNumber = numbers[index];
}
cout << isDescending << endl;
delete[] numbers;
return 0;
}