当前位置:网站首页>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;
}
边栏推荐
- How to share the source code anti disclosure scheme
- Used on windows Bat file startup project
- Why does the producer / consumer mode wait () use while instead of if (clear and understandable)
- How to send mail with Jianmu Ci
- Mysql database - function constraint multi table query transaction
- 手写简易版flexible.js以及源码分析
- Docker install MySQL
- Blog stop statement
- Cell reports: Wei Fuwen group of the Institute of zoology, Chinese Academy of Sciences analyzes the function of seasonal changes in the intestinal flora of giant pandas
- Introduction to rce in attack and defense world
猜你喜欢

flask-sqlalchemy 循环引用
![[kubernetes series] kubesphere is installed on kubernetes](/img/2b/eb39cf78b3bb9908b01f279e2f9958.png)
[kubernetes series] kubesphere is installed on kubernetes

The cloud native programming challenge ended, and Alibaba cloud launched the first white paper on application liveliness technology in the field of cloud native

Flink memory model, network buffer, memory tuning, troubleshooting

Zephyr 学习笔记1,threads

Introduction to rce in attack and defense world
![[web security] nodejs prototype chain pollution analysis](/img/b6/8eddc9cbe343f2439da92bf342b0dc.jpg)
[web security] nodejs prototype chain pollution analysis

Vulhub vulnerability recurrence 77_ zabbix

Research on an endogenous data security interaction protocol oriented to dual platform and dual chain architecture

Go learning notes - constants
随机推荐
flask-sqlalchemy 循环引用
人生规划(Flag)
Boosting the Performance of Video Compression Artifact Reduction with Reference Frame Proposals and
MySQL中的文本处理函数整理,收藏速查
Electronic Association C language level 1 35, bank interest
两年前美国芯片扭捏着不卖芯片,如今芯片堆积如山祈求中国帮忙
Introduction to deep learning Ann neural network parameter optimization problem (SGD, momentum, adagrad, rmsprop, Adam)
It's healthy to drink medicinal wine like this. Are you drinking it right
Vulhub vulnerability recurrence 76_ XXL-JOB
Book list | as the technical support Party of the Winter Olympics, Alibaba cloud's technology is written in these books!
Jianmu continuous integration platform v2.2.2 release
2022-021rts: from the second half of the year
[Flink] temporal semantics and watermark
Advanced MySQL: Basics (5-8 Lectures)
University stage summary
Detailed introduction to the big changes of Xcode 14
In the era of low code development, is it still needed?
[web security] nodejs prototype chain pollution analysis
【FreeRTOS】FreeRTOS学习笔记(7)— 手写FreeRTOS双向链表/源码分析
[C language] open the door of C