当前位置:网站首页>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;
}
边栏推荐
- Write a thread pool by hand, and take you to learn the implementation principle of ThreadPoolExecutor thread pool
- The cloud native programming challenge ended, and Alibaba cloud launched the first white paper on application liveliness technology in the field of cloud native
- 在所有SwiftUI版本(1.0-4.0)中原生实现Charts图表视图之思路
- BibTex中参考文献种类
- kubernetes集群之Label管理
- [Valentine's day] - you can change your love and write down your lover's name
- Data double write consistency between redis and MySQL
- 手写简易版flexible.js以及源码分析
- Boosting the Performance of Video Compression Artifact Reduction with Reference Frame Proposals and
- The IP bound to the socket is inaddr_ The meaning of any htonl (inaddr_any) (0.0.0.0 all addresses, uncertain addresses, arbitrary addresses)
猜你喜欢
Splicing plain text into JSON strings - easy language method
CMS source code of multi wechat management system developed based on thinkphp6, with one click curd and other functions
The idea of implementing charts chart view in all swiftui versions (1.0-4.0) was born
BasicVSR++: Improving Video Super-Resolutionwith Enhanced Propagation and Alignment
There is no Chinese prompt below when inputting text in win10 Microsoft Pinyin input method
[kubernetes series] kubesphere is installed on kubernetes
Vulhub vulnerability recurrence 76_ XXL-JOB
Deep profile data leakage prevention scheme
How to share the source code anti disclosure scheme
果果带你写链表,小学生看了都说好
随机推荐
win10微软拼音输入法输入文字时候下方不出现中文提示
深入浅出:了解时序数据库 InfluxDB
tornado项目之路由装饰器
2022-021ARTS:下半年開始
Xcode 14之大变化详细介绍
提升复杂场景三维重建精度 | 基于PaddleSeg分割无人机遥感影像
A real penetration test
电脑通过Putty远程连接树莓派
Literature collation and thesis reading methods
Routing decorator of tornado project
Pangu open source: multi support and promotion, the wave of chip industry
The most effective futures trend strategy: futures reverse merchandising
tornado之目录
Rhcsa day 3
flask-sqlalchemy 循环引用
[Mori city] random talk on GIS data (I)
Vulhub vulnerability recurrence 76_ XXL-JOB
Redis - detailed explanation of cache avalanche, cache penetration and cache breakdown
Review of enterprise security incidents: how can enterprises do a good job in preventing source code leakage?
Docker install MySQL