📄 1007.cpp
字号:
// 1007.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<iostream.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
class sss
{
public:
char ch[51];
int key;
friend bool operator<(const sss a,const sss b)
{
return ((a.key)<(b.key));
}
};
int val_key(char *ch,int len)
{
int i,j,t=0;
for(i=0;i<len;i++)
{
for(j=i+1;j<len;j++)
{
if(ch[i]>ch[j])
{t++;}
}
}
return t;
}
void main()
{
int len,num;
cin>>len>>num;
int i;
sss p[101];
for(i=0;i<num;i++)
{
cin>>p[i].ch;
(p[i]).ch[len]='\0';
p[i].key=val_key(p[i].ch,len);
}
stable_sort(p,p+num);
for(i=0;i<num;i++)
{
cout<<p[i].ch<<endl;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -