I want to make a program which should read a number n, which describes, how much numbers are goig to be read by the computer.
Those n numbers have to be read in the next line. If the order of those numbers is ascendent (so, the second is greater than the first and so on), YES should be cout and if not every number increases the left one NO.
My program:
#include <iostream>
int main()
{
int n;
std::cin >> n;
int a;
if (n-- > 0) std::cin >> a;
bool good = true;
while (good && n-- > 0)
{
int b = a;
std::cin >> a;
if (a <= b) good = false;
}
std::cout << (good ? "YES\n" : "NO\n");
}