标签:return lan ret ++ stream using str flag ios
#include<iostream>
using namespace std;
int main() {
int data[1010];
int n, sum = 0;
int flag = 0;
cin >> n;
cin >> data[0] >> data[1];
flag = (data[1] > data[0]);
for (int i = 2; i < n; i++) {
cin >> data[i];
if (flag&&data[i] < data[i - 1]) {
flag = 0; sum++;
}
else if (!flag&&data[i] > data[i - 1]) {
flag = 1; sum++;
}
else {
flag = (data[i] > data[i - 1]);
}
}
cout << sum << endl;
return 0;
}
标签:return lan ret ++ stream using str flag ios
原文地址:https://www.cnblogs.com/CSE-kun/p/14587142.html