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

哪位大牛帮我看看为什么会ole啊????

Posted by zhprintf at 2008-08-28 23:30:47 on Problem 1007
#include<stdio.h>
int measure(char string[],int m)
{
    int measure=0;
    int i;
    int j;
    for(i=0;i<m-1;i++)
    {
                    for(j=i+1;j<m;j++)
                    if(string[i]>string[j])
                    measure++; 
    }
    return measure;
}                                        
int main()
{
    char string[100][50];
    char *s[100];
    char *p;
    int i,j;
    int n,m;
    scanf("%d%d",&m,&n);
    for(i=0;i<n;i++)
    {
     scanf("%s",string[i]);
     s[i]=string[i];
    }    
    for(i=0;i<n-1;i++)
    {
                      for(j=0;j<n-1-i;j++)
                      {
                                          if(measure(s[j],m)>measure(s[j+1],m))
                                          {
                                            p=s[j];
                                            s[j]=s[j+1];
                                            s[j+1]=p;
                                          }
                      }
    }
    for(i=0;i<n;i++)
    printf("%s\n",s[i]);
}

    
    
    

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