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 |
why WA,can someone help?thank you //code as follow #include <iostream> using namespace std; #define N 10005 #define M 35 char tree[N][M],num[N]; int nindex; void insert(char *s) { int low=0; int up=nindex-1; int i,mid; while(low<=up){ mid=(low+up)>>1; if(strcmp(tree[mid],s)==0){ num[mid]++; return ; } else if(strcmp(tree[mid],s)<0) low=mid+1; else up=mid-1; } for(i=nindex;i>low;i--) { strcpy(tree[i],tree[i-1]); num[i]=num[i-1]; } strcpy(tree[low],s); num[low]=1; nindex++; } int main() { // freopen("a.txt","r",stdin); int n,i; char s[M]; nindex=0; n=0; while(gets(s)) { n++; insert(s); } for(i=0;i<nindex;i++) printf("%s %.4f\n",tree[i],num[i]*100/(double)n); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator