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

为什么一直WA?求解释

Posted by zhouyusong at 2011-10-25 15:54:05 on Problem 1007
#include <iostream>
#include<stdio.h>
using namespace std;
int cmp(const void* a,const void* b)
{
  return (*(int*)a-*(int*)b);
}
int main()
{
    int n[55];
    char s[55][105];
    int m,len;
    cin>>len>>m;
    for(int i=0;i<m;i++)
    {
        scanf("%s",s[i]);
        n[i]=0;
        for(int j=0;j<len-1;j++)
        {
            for(int k=j+1;k<len;k++)
            if(s[i][j]>s[i][k])n[i]++;
        }
        n[i]=n[i]*10000+i;
    }
    qsort(n,m,sizeof(n[0]),cmp);
    for(int i=0;i<m;i++)
    printf("%s\n",s[n[i]%10000]);
    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