|
|
back to boardcompilation error why did i get compilation error? here is my program: <#include<iostream> using namespace std; #define N 500 int num; int denote[N],c[N],len[N]; int length; void quick_sort(int st[N][2],int low,int high,int pi); void print() { int mem[N][2]; int k=1; for(int i=1;i<=num;i++) if(c[i]==1) { mem[k][0]=len[i]; mem[k][1]=i; k++; } quick_sort(mem,1,k-1,1); if(k==1) cout<<1<<endl; else { for(i=1;i<=k-1;i++) cout<<mem[i][1]<<' '; cout<<endl; } } void quick_sort(int st[N][2],int low,int high,int pi) { int head=low,tail=high; st[0][0]=st[pi][0]; st[0][1]=st[pi][1]; if(low>=high) ; else { while(low<high) { while(low<high&&st[high][0]>=st[0][0]) high--; st[low][0]=st[high][0]; st[low][1]=st[high][1]; while(low<high&&st[low][0]<st[0][0]) low++; st[high][0]=st[low][0]; st[high][1]=st[low][1]; } st[low][0]=st[0][0]; st[low][1]=st[0][1]; quick_sort(st,head,low-1,head); quick_sort(st,high+1,tail,high+1); } } int main() { int lp[N][2],rp[N]; int i,j,k=1; cin>>num; for(i=1;i<=num;i++) { cin>>lp[i][0]>>rp[i]; len[i]=rp[i]-lp[i][0]; lp[i][1]=i; } memset(c,0,sizeof(c)); quick_sort(lp,1,num,1); length=1; denote[num]=1; for(i=num-1;i>0;i--) { denote[i]=1; for(j=i+1;j<=num;j++) { if(lp[i][0]!=lp[j][0]) if(rp[lp[i][1]]>rp[lp[j][1]]) if(denote[i]<denote[j]+1) { denote[i]=denote[j]+1; if(length<denote[i]) { c[lp[i][1]]=1; if(length==1) c[lp[j][1]]=1; length=denote[i]; } } } } cout<<length<<endl; print(); return 0; } Edited by author 24.04.2007 11:29 Re: compilation error First write #include <iostream> instead of <#include <iosteream> Second declar indentifier i in for(int i=1;i<=num;i++) { ... } instead of for(i=1;i<=num;i++) { ... } Re: compilation error the first you mentioned is my mistaken writing when i am editing.the second is the reason i get CE.thank you so much. Re: compilation error You're welcome :) |
|
|