求助dalao,只得了10分。不知道问题在哪

P1567 统计天数

@[liyingqi](/space/show?uid=115318) #include<bits/stdc++.h> using namespace std; long a[10000],b=0,cnt=0,n,tmp; int main() { cin>>n; for(int i=0;i<n;i++) cin>>a[i]; tmp=0; for(int i=0;i<n;i++) { if(a[i]>tmp) { tmp=a[i]; cnt++; } else if(a[i]<=tmp) { if(cnt>b) b=cnt; cnt=1; tmp=a[i]; } } cout<<b; }
by liyingqi @ 2018-09-09 08:46:10


@[liyingqi](/space/show?uid=115318) 上面那个改了一下,现在有30分了
by liyingqi @ 2018-09-09 08:51:17


#include<bits/stdc++.h> using namespace std; long a[10000],b=0,cnt=0,n,tmp; int main() { cin>>n; for(int i=0;i<n;i++) cin>>a[i]; tmp=0; for(int i=0;i<n;i++) { if(a[i]>tmp) { tmp=a[i]; cnt++; if(cnt>b) b=cnt; } else if(a[i]<=tmp) { cnt=1; tmp=a[i]; } } cout<<b; }
by liyingqi @ 2018-09-09 09:00:03


include<bits/stdc++.h> using namespace std; long a[10000],b=0,cnt=0,n,tmp; int main() { cin>>n; for(int i=0;i<n;i++) cin>>a[i]; tmp=0; for(int i=0;i<n;i++) { if(a[i]>tmp) { tmp=a[i]; cnt++; if(cnt>b) b=cnt; } else if(a[i]<=tmp) { cnt=1; tmp=a[i]; } } cout<<b; }
by LgxTpre @ 2018-09-09 09:07:50


tmp=0可以去掉
by LgxTpre @ 2018-09-09 09:08:25


cnt的初始化应该是1吧
by LgxTpre @ 2018-09-09 09:09:05


@[liyingqi](/space/show?uid=115318)
by LgxTpre @ 2018-09-09 09:09:21


好的,谢谢各位大佬。我数组越界了。。。。。。。。。。。。。
by liyingqi @ 2018-09-09 09:12:28


@[管小二](/space/show?uid=66709) 数组长度不够,然后我改了一下。就ac了,谢谢dalao。
by liyingqi @ 2018-09-09 09:20:51


没事
by LgxTpre @ 2018-09-09 09:21:40


| 下一页