链接: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 ",ans); } return 0; }