标签:mes nbsp const div 北京 amp for highlight std
基本思想:
无;
关键点:
无;
#include<iostream> #include<string> #include<algorithm> #include<vector> using namespace std; const int maxn = 90; bool flag[maxn]; int num[maxn]; int main() { int n; while (cin >> n) { fill(flag, flag + n, false); for (int i = 0; i < n; i ++ ) { cin >> num[i]; } for (int i = 0; i < n; i++) { if (i == 0) { if (num[0] != num[1]) flag[i] = true; }else if (i == n-1) { if (num[i] != num[i-1]) flag[i] = true; } else { if ((num[i] > num[i - 1] && num[i] > num[i + 1]) || (num[i] < num[i - 1] && num[i] < num[i + 1])) flag[i] = true; } } for (int i = 0; i < n; i++) { if (flag[i]) cout << i << " "; } cout << endl; } }
标签:mes nbsp const div 北京 amp for highlight std
原文地址:https://www.cnblogs.com/songlinxuan/p/12458102.html