您的位置:首页 > 其它

NYOJ 370 波动序列

2014-05-23 21:48 176 查看
链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=370

 

 

 

#include <iostream>
#include<cstdio>
using namespace std;
int main()
{
int t;
int n;
int i;
int a;
int last;
bool s;
int ans;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
s=true;
scanf("%d",&last);
ans=1;
for(i=1;i<n;i++)
{
scanf("%d",&a);
if(!s&&a>last)
{
ans++;
s=true;
}
else if(s&&a<last)
{
ans++;
s=false;
}
last=a;

}

printf("%d\n",ans);

}

return 0;
}


 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ACM