Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main () {
  5. int n;
  6. cin >> n;
  7. int countloi = 0;
  8. int countlom = 0;
  9. int a[100];
  10. for (int i = 0; i < n ; ++i) {
  11. cin >> a[i];
  12. }
  13. if ( n < 3 ) {
  14. cout << "Vo danh";
  15. }
  16. for (int j = 1; j < n - 1 ; ++j) {
  17. if (a[j] > a[j-1] && a[j] > a[j+1]) {
  18. countloi = countloi + 1;
  19. }
  20. if (a[j] < a[j-1] && a[j] < a[j+1] ) {
  21. countlom = countlom + 1;
  22. }
  23. }
  24. if (countloi == 1) {
  25. cout << "Loi";
  26. } else if (countlom == 1) {
  27. cout << "Lom";
  28. } else cout << "Vo danh";
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement