绳子问题

#include <stdio.h>   
int overrideMaxNum(int *points,int pointsNum,int L)  
{  
    int maxNum=1,i=0,j=1;  
    if(L<=0||points==NULL||pointsNum<=0)return 0;  
    while(j<pointsNum)  
    {  
        while(j<pointsNum&&points[j]-points[i]<=L)  
        {  
            maxNum++;  
            j++;  
        }  
        i++;  
        j++;  
    }  
    return maxNum;  
}  
int main()  
{  
    int points[10]={1,2,3,4,10,15,17,18,19,20};  
    printf("%d\n",overrideMaxNum(points,10,3));  
    return 0;  
}  

 

posted @ 2013-10-05 23:49  l851654152  阅读(260)  评论(0编辑  收藏  举报