| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
我亲爱的程序,你错哪了#include<iostream>
using namespace std;
int main()
{
int n,i,j,t,a[30001],loop,k,MAX,ans;
bool flag;
cin>>n;
for(i=0;i<n;i++)
{
cin>>t;
for(j=0;j<t;j++)
cin>>a[j];
MAX=1;
for(j=0;j<t-1;j++)
{
flag=true;
ans=1;
for(k=j+1;k<t;k++)
{
loop=0;
if(flag&&loop==0)
{
if(a[k]<a[k-1])
{
ans++;
flag=false;
loop=1;
}
}
else if(!flag&&loop==0)
{
if(a[k]>a[k-1])
{
ans++;
flag=true;
loop=1;
}
}
if(loop==0)
break;
}
if(ans>MAX)
MAX=ans;
}
cout<<MAX<<endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator