原题
###代码
#include <iostream>
using namespace std;
int main() {
int n=0,count=0;
cin>>n;
//yset:昨天的值 tod:今天的值 yest_c:前天与昨天的差值 tid_c:今天与昨天的差值
int yest=0, tod=0, yest_c = 0, tod_c =0;
for(int i=0; i<n; i++){
cin>>tod;
if(i == 0)
yest=tod;//第一天
else{
tod_c = tod - yest; // 今天与昨天的差值
if((tod_c>0 && yest_c <0) || (tod_c<0 && yest_c>0)) //如果出现折点
count++;
yest_c = tod_c; // 今天的差值变成昨天的差值,进入下一天
}
}
cout<<count<<endl;
return 0;
}
运行结果
·
求大佬们看看问题在哪里