L1-027 出租 (20分)
程序员文章站
2022-04-02 11:21:44
...
#include <bits/stdc++.h>
using namespace std;
string str;
int tel[13],ar[13],ind[13];
int vis[11],c;
bool cmp(int a,int b){
return a > b;
}
int main(){
ios::sync_with_stdio(0);
cin >> str;
for(int i = 0; i < 11; i++){
tel[i] = str[i] - '0';
if(!vis[tel[i]]){
ar[c++] = tel[i];
vis[tel[i]] = 1;
}
}
sort(ar,ar+c,cmp);
cout << "int[] arr = new int[]{";
for(int i = 0; i < c; i++){
if(i) cout << ",";
cout << ar[i];
}
cout << "};" << endl;
for(int i = 0; i < 11; i++){
for(int j = 0; j < c; j++){
if(ar[j] == tel[i])
ind[i] = j;
}
}
cout << "int[] index = new int[]{";
for(int i = 0; i < 11; i++){
if(i) cout << ",";
cout << ind[i];
}
cout << "};" << endl;
return 0;
}
上一篇: Python实现计算器
下一篇: 爱情是鸦片?老板,来盘寂寞