当前位置:网站首页>L1-027 rental (20 points)
L1-027 rental (20 points)
2022-07-04 07:29:00 【Inter personal liabilities^】
L1-027 lease (20 branch )
Here is a picture of sina Weibo that used to be very popular :
At one time, the Internet was full of cries for help , How to break this . In fact, this code is very simple ,index Array is arr Index of the array ,index[0]=2 Corresponding arr[2]=1,index[1]=0 Corresponding arr[0]=8,index[2]=3 Corresponding arr[3]=0, And so on …… It's easy to get a phone number 18013820100.
This question asks you to write a program , Generate this code for any phone number —— in fact , Just generate the first two lines , The rest is the same .
Input format :
Type in a line to give a result of 11 A cell phone number made up of digits .
Output format :
Generate the first two lines of code for the entered number , among arr The numbers in must be given in descending order .
sample input :
18013820100
sample output :
int[] arr = new int[]{8,3,2,1,0};
int[] index = new int[]{3,0,4,3,1,0,2,4,3,4,4};
AC Code
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<sstream>
using namespace std;
typedef long long ll;
const int N=100010;
bool bo[15];
int main()
{
string a;
cin >> a;
int arr[15];
for(int i = 0; i < a.size(); i ++ )
if(!bo[a[i] - '0']) bo[a[i] - '0'] = true;
int k = 0;
for(int i = 9; i >= 0; i -- )
if(bo[i]) arr[k ++ ] = i;
int index[15];
int l = 0;
for(int i = 0; i < a.size(); i ++ )
for(int j = 0; j < k; j ++ )
if(a[i] - '0' == arr[j])
index[l ++ ] = j;
cout << "int[] arr = new int[]{";
for(int i = 0; i < k; i ++ )
{
if(i != k - 1) cout << arr[i] << ',';
else cout << arr[i] << "};" << endl;
}
cout << "int[] index = new int[]{";
for(int i = 0; i < l; i ++ )
{
if(i != l - 1) cout << index[i] << ',';
else cout << index[i] << "};" << endl;
}
return 0;
}
边栏推荐
- Data double write consistency between redis and MySQL
- Distributed transaction management DTM: the little helper behind "buy buy buy"
- MySQL storage engine
- rapidjson读写json文件
- com. alibaba. nacos. api. exception. NacosException
- Knowledge payment applet dream vending machine V2
- Introduction to deep learning Ann neural network parameter optimization problem (SGD, momentum, adagrad, rmsprop, Adam)
- 【Kubernetes系列】Kubernetes 上安装 KubeSphere
- 【FreeRTOS】FreeRTOS學習筆記(7)— 手寫FreeRTOS雙向鏈錶/源碼分析
- MYCAT middleware installation and use
猜你喜欢

大厂技术专家:架构设计中常用的思维模型

How to share the source code anti disclosure scheme

Blog stop statement

Knowledge payment applet dream vending machine V2

Detailed introduction to the big changes of Xcode 14

Vulhub vulnerability recurrence 76_ XXL-JOB

MySQL storage engine

Data double write consistency between redis and MySQL
![[kubernetes series] kubesphere is installed on kubernetes](/img/2b/eb39cf78b3bb9908b01f279e2f9958.png)
[kubernetes series] kubesphere is installed on kubernetes

Tri des fonctions de traitement de texte dans MySQL, recherche rapide préférée
随机推荐
Introduction to sap commerce cloud B2B organization function
How to input single quotation marks and double quotation marks in latex?
Four sets of APIs for queues
Go learning notes - constants
MySQL storage engine
电脑通过Putty远程连接树莓派
[C language] open the door of C
Book list | as the technical support Party of the Winter Olympics, Alibaba cloud's technology is written in these books!
Review of enterprise security incidents: how can enterprises do a good job in preventing source code leakage?
Introduction to deep learning Ann neural network parameter optimization problem (SGD, momentum, adagrad, rmsprop, Adam)
Implementation of ZABBIX agent active mode
The important role of host reinforcement concept in medical industry
The most effective futures trend strategy: futures reverse merchandising
Rhcsa day 3
MySQL error resolution - error 1261 (01000): row 1 doesn't contain data for all columns
The idea of implementing charts chart view in all swiftui versions (1.0-4.0) was born
Advanced MySQL: Basics (5-8 Lectures)
socket inet_ pton() inet_ Ntop() function (a new network address translation function, which converts the expression format and numerical format to each other. The old ones are inet_aton(), INET_ ntoa
Detailed introduction to the big changes of Xcode 14
Xcode 14之大变化详细介绍