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 |
LIS but wrong code???#include<stdio.h> #define N 1001 int length[N],data[N]; int LIS(int data[],int n) { int i,j; for(i=0;i<=n;i++)length[i]=1; for(i=1;i<=n-1;i++) for(j=i+1;j<=n;j++) if(data[j]>data[i]) if(length[i]+1>length[j]) length[j]=length[i]+1; return length[n]; } int main() { int n; while(scanf("%d",&n)!=EOF) { for(int i=1;i<=n;i++) scanf("%d",&data[i]); printf("%d\n",LIS(data,n)); //for(i=0;i<=n;i++)printf("%d ",length[i]); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator