Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main () {
- int n;
- cin >> n;
- int countloi = 0;
- int countlom = 0;
- int a[100];
- for (int i = 0; i < n ; ++i) {
- cin >> a[i];
- }
- if ( n < 3 ) {
- cout << "Vo danh";
- }
- for (int j = 1; j < n - 1 ; ++j) {
- if (a[j] > a[j-1] && a[j] > a[j+1]) {
- countloi = countloi + 1;
- }
- if (a[j] < a[j-1] && a[j] < a[j+1] ) {
- countlom = countlom + 1;
- }
- }
- if (countloi == 1) {
- cout << "Loi";
- } else if (countlom == 1) {
- cout << "Lom";
- } else cout << "Vo danh";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement