| ||||||||||
| 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 | |||||||||
为什么runtime error?谢了#include<stdio.h>
#include<stddef.h>
struct node
{
int val;
char* str;
node* nxt;
};
void insert(node* head,node* nn)
{
if(head==NULL)
head=nn;
else if(head->val>nn->val)
{
nn->nxt=head;
head=nn;
}
else
{
node* p=head;
while(p+1!=NULL)
while((p+1)->val<=nn->val)
p++;
p->nxt=nn;
}
}
int unsortedness(char* str)
{
char* p1=str;
int usn;
char* p2=p1+1;
while(p2!='\0')
{
if(*p2<*p1)
usn++;
}
if(p1+1!='\0')
usn+=unsortedness(p1+1);
return usn;
}
int main()
{
int len,n;
node* head=NULL;
scanf("%d%d",&len,&n);
while(n-->0)
{
char *p;
scanf("%s",p);
node *np=new node;
np->str=p;
np->val=unsortedness(p);
insert(head,np);
}
while(head++!=NULL)
printf("%s\n",head->str);
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator