1 Star 0 Fork 0

util6/算法刷题c++

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Weekst3.cpp 468 Bytes
一键复制 编辑 原始数据 按行查看 历史
util6 提交于 2022-04-02 21:39 +08:00 . 默认的
/**
* @author 大菜狗
*/
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const int N = 100010;
int n,a[N];
int main(){
ios::sync_with_stdio(false);
cin>>n;
if (n<=2){
puts("0");
return 0;
}
for(int i = 0; i <n; i++) {
cin>>a[i];
}
int res = 0;
for(int i = 1; i <n-1; i++) {
int j = i-1,k = i+1;
if (a[j]<a[i]&&a[k]<a[i]||a[j]>a[i]&&a[k]>a[i]){
res++;
}
}
cout<<res;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/liuyutaocode/cppCode.git
git@gitee.com:liuyutaocode/cppCode.git
liuyutaocode
cppCode
算法刷题c++
master

搜索帮助