#include <stdio.h> #include <string.h> #define MAXSIZE 100024//之前数据少开了一个量级 int money[MAXSIZE]; int main() { memset(money, 0, sizeof(money)); int a; scanf("%d", &a); int Thiscnt=1, Maxcnt=1;//如果Maxcnt=-1;那么当a为1的时候,for循环不会执行,进而导致输入结果为-1(出错)。 int i; int cnt=0; scanf("%d", &money[0]); for(i=0; i<(a-1); ++i) { ++cnt; scanf("%d", &money[i+1]); //printf("i+1=%d,money[%d]=%d ", i+1, i+1, money[i+1]); if(money[i]<=money[i+1]) //a[i];a[i-1] is wrong.money[i-1] is wrong. { ++Thiscnt; //printf("cnt=%d:Thiscnt=%d\n", cnt, Thiscnt); } else Thiscnt=1; if(Thiscnt>Maxcnt) Maxcnt=Thiscnt; } printf("%d\n", Maxcnt); return 0; }