题干略
题干复制下来就原创审核不通过 离谱
AC代码:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int isprime(int a)
{
if (a == 0 || a == 1)
{
return 0;
}
else
{
for (int i = 2; i <= sqrt(a); i++)
{
if (a % i == 0)
return 0;
}
return 1;
}
}
int main()
{
int a[10] = {0};
char t;
vector<int> arr;
int index[11];
int num[11];
for (int i = 0; i < 11; i++)
{
cin >> t;
num[i] = t-'0';
a[t-'0']++;
}
for (int i = 9; i >= 0; i--)
{
if (a[i] != 0)
{
arr.push_back(i);
}
}
cout << "int[] arr = new int[]{";
for (int i = 0; i < arr.size(); i++)
{
if (i == 0)
cout << arr[i];
else
cout << "," << arr[i];
}
cout << "};\n";
cout << "int[] index = new int[]{";
for (int i = 0; i < 11; i++)
{
for (int j = 0; j < arr.size(); j++)
{
if (num[i] == arr[j])
{
if (i == 0)
cout << j;
else
cout << "," << j;
break;
}
}
}
cout << "};";
return 0;
}
水题找回自信(自欺欺人)