| ||||||||||
| 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 | |||||||||
大神们我的哪错了啊,测试案例是对的就是WA#include<stdio.h>
#include<string.h>
// #include<stdlib.h>
#include<algorithm>
using namespace std;
struct nu{
int index;
int sort;
};
bool cmp1(struct nu a,struct nu b)
{
return a.sort<b.sort;
}
// int cmp(const void *a,const void *b)
// {
// return ((struct nu*)a)->sort>((struct nu*)b)->sort;
// }
int algorithm_count(char *s,int n)
{
int count=0;
for (int i = 0; i <n-1; i++)
{
/* code */
for (int j = i+1; j < n; j++)
{
/* code */
if(s[i]>s[j])
{
count++;
}
}
}
return count;
}
int main()
{
int n,m;
scanf("%d %d",&n,&m);
char str[101][51];
struct nu num[51];
for(int i=0;i<m;i++)
{
scanf("%s",str[i]);
num[i].sort=algorithm_count(str[i],n);
num[i].index=i;
//计算该序列的整齐度
}
sort(num,num+m,cmp1);
// qsort(num,m,sizeof(struct nu),cmp);
// printf("\n");
for(int i=0;i<m;i++)
{
printf("%s\n",str[num[i].index]);
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator