#include #include #include #include using namespace std;

int n, m; string a[55]; int t[110] = { 0 }, r[110];

int s(string a) { int sum = 0; for (int i = 0; i < a.length() - 1; i++) for (int j = i + 1; j < a.length(); ++j) if (a[i] > a[j]) sum++; return sum; }

int main() { int x = 0; scanf_s("%d%d", &n, &m); for (int i = 0; i < m; ++i) { cin >> a[i];

}

for (int i = 0; i < m; i++)
{
    t[i] = s(a[i]);
    r[i] = t[i];
}
sort(t, t + m);
for (int i = 0; i < m; i++)
    for (int j = 0; j < m; j++)
    {
        if (t[i] == r[j])
            cout << a[j] << endl;
    }
return 0;
请把以下代码改写为c++语言:#include iostream#include cstdio#include cstring#include algorithmusing namespace std; int n m;string a55;int t110=0r110; int sstring a	int sum = 0;	forint i = 0; i alength-1; i++	 f

原文地址: https://www.cveoy.top/t/topic/fjrg 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录