当前位置:网站首页>刷题-洛谷-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;
}
边栏推荐
猜你喜欢
随机推荐
PG网络传输安全SSL介绍及使用示例
[Awards for Essays] Autumn recruitment special training to create your exclusive product experience
电脑一键重装系统内存完整性无法打开怎么办
The establishment of simple data cache layer
2022年7月国产数据库大事记
Infrared image filtering
华为企业组网实例:VRRP+MSTP典型组网配置
Storage resource activation system to help new infrastructure
如何让远在的老板看到你!----------来自财富中国网
A complete cross-compilation environment records the shell scripts generated by peta
The book "The Essence of Alipay Experience Design", a record of knowledge related to testing
华为交换机:STP测试实验
【着色器实现Glitch单项故障闪烁效果(与Television效果不同)_Shader效果第十四篇】
How to monitor code cyclomatic complexity by refactoring indicators
Use "green computing" technology to promote sustainable development of computing power
Highlights of some performance tests
存储资源盘活系统助力新基建
PostgreSQL的 SPI_接口函数
awk statistical average max min
《支付宝体验设计精髓》一书,跟测试相关性知识记录