当前位置:网站首页>刷题-洛谷-P1317 低洼地
刷题-洛谷-P1317 低洼地
2022-08-04 19:44:00 【宋向上_UP】
P1317 低洼地-C语言
1、题目

2、求解过程
结果:
代码:
//洛谷 P1317 低洼地
#include <stdio.h>
#define NUM 10000
int main() {
int n;
int level[NUM];//水平高度
int i,j;
int counter = 0;//计数器
scanf("%d", &n);
j = 0;
for (i = 0; i < n; i++) {
//输入n次
scanf("%d", &level[j]);
if (level[j] == level[j - 1]) {
//出现平台
j = j - 1;
}
j++;
}
for (i = 1; i < n-1; i++) {
if (level[i] < level[i - 1] && level[i] < level[i + 1]) {
counter++;//统计低洼地
}
}
printf("%d", counter);
return 0;
}
边栏推荐
猜你喜欢
随机推荐
JSD-2204-酷莎商城(管理员模块)-密码加密-Day10
Order of lds links
【有奖征文】秋招特训,打造你的专属产品体验
奥拉时钟芯片生成配置文件脚本
The establishment of simple data cache layer
Orthodontic MIA micro-implant anchorage technology China 10th anniversary exchange meeting was held in Shenyang
电脑一键重装系统后连不上远程了?教你设置的方法
如何推动乡村振兴的落地
How to monitor code cyclomatic complexity by refactoring indicators
如何让远在的老板看到你!----------来自财富中国网
Highlights of some performance tests
使用.NET简单实现一个Redis的高性能克隆版(二)
awk statistical difference record
ELECTRA: Pre-training Text Encoders as Discriminators Rather Than Generators
简易数据缓存层的建立
zynq records
华为WLAN技术:AP上线及相关模板的配置实验
IIC驱动OLED
正则表达式未完
seata源码解析:seata server各种消息处理流程








