欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

L1-027 出租 (20分)

程序员文章站 2022-04-02 11:21:44
...

L1-027 出租 (20分)

L1-027 出租 (20分)

#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;
}
相关标签: 天梯赛