#include "iostream"
#include "string"
#include "algorithm"
using namespace std;
struct Info
{
string str;
int count;
}info[110];
bool cmp(Info a, Info b)
{
return a.count < b.count;
}
int main()
{
int len, num, i, j, k;
cin >> len >> num;
for (i = 0; i < 110; i++)
info[i].count = 0;
for (i = 0; i < num; i++)
{
cin >> info[i].str;
for (j = 0; j < len; j++)
{
for (k = j + 1; k < len; k++)
if (info[i].str[j] > info[i].str[k])
info[i].count++;
}
}
sort(info, info+num, cmp);//结构体的排序!
for (i = 0; i < num; i++)
cout << info[i].str << endl;
system("pause");
}
poj 1007 DNA Sorting
最新推荐文章于 2018-05-02 17:53:23 发布