Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

好象有要求 stable_sort()

Posted by sunmoonstar at 2006-05-16 14:22:13 on Problem 1007
In Reply To:检查了N次,还是没发现错误,请高手指教。 Posted by:KeMu at 2006-05-16 14:19:30
> int num1,num2;
> int fan(char *p)
> {   int measure=0;
>     char *s,*q;
>     for(s=p;s<p+num1-1;s++)
>     for(q=s+1;q<p+num1;q++)
>     if(*q<*s)measure++;
>     return(measure);
> }
> 
> #include<stdio.h>
> #include<string.h>
> int main()
> {  char a[50][100],c[50];
>    int  b[100];
>    int i,j,t;
>    scanf("%d%d",&num1,&num2);
>    for(i=0;i<num2;i++)
>    { 
>      scanf("%s",a[i]);
>      b[i]=fan(a[i]);
>    }
>    
>    for(i=0;i<num2-1;i++)
>    for(j=0;j<num2-1-i;j++)
>    { if(b[j+1]<b[j])
>      t=b[j];b[j]=b[j+1];b[j+1]=t;
>      strcpy(c,a[j]);
>      strcpy(a[j],a[j+1]);
>      strcpy(a[j+1],c); 
>    }
>    
>    printf("\n");
>    for(i=0;i<num2;i++)
>    {
>      for(j=0;j<num1;j++)
>      printf("%c",a[i][j]);
>      printf("\n");
>    }
>    return 0;
> }
>  

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator