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 |
请高人看看,小弟初学ACM不知道用什么方法做题效率高,还有这题的代码自己测试正确,这里确实WA,感激涕零~~#include<stdio.h> #include<stdlib.h> char a[5200]; int length,total,b[202],*c=b-1; typedef struct lis{int i;int j;struct lis *next;}lis; lis * initial(lis *a) { a=(lis *)malloc(sizeof(lis)); a->next=NULL; return a; } lis * in(lis *a,int i,int j) { lis *p,*q,*r; p=(lis *)malloc(sizeof(lis)); p->i=i; p->j=j; p->next=NULL; if(!a->next) { a->next=p; // p->next=NULL; return a; } r=a; q=a->next; while(q!=NULL&&q->i<=i) { q=q->next; r=r->next; } p->next=r->next; r->next=p; return a; // p->next=q->next; // q->next=p; // return a; } int main() { lis *p; int i,j,k; scanf("%d %d",&length,&total); for(i=0;i<total;i++) { scanf("%s",a+i*52); *(a+(i+1)*52-1)=0; } for(i=0;i<total;i++) { for(j=0;j<length;j++) { for(k=j+1;k<length;k++) { if(a[i*52+k]<a[i*52+j]) *(a+(i+1)*52-1)=*(a+(i+1)*52-1)+1; } } } p=initial(p); for(i=0;i<total;i++) { p=in(p,*(a+(i+1)*52-1),i); } p=p->next; // printf("\n"); while(p) { printf("%s\n",a+p->j*52); p=p->next; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator