当前位置:网站首页>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;
}
边栏推荐
- Life planning (flag)
- 输入年份、月份,确定天数
- Boast about Devops
- Rapidjson reading and writing JSON files
- flask-sqlalchemy 循环引用
- With excellent strength, wangchain technology, together with IBM and Huawei, has entered the annual contribution list of "super ledger"!
- win10微软拼音输入法输入文字时候下方不出现中文提示
- Xcode 14之大变化详细介绍
- University stage summary
- SQL foundation 9 [grouping data]
猜你喜欢
CMS source code of multi wechat management system developed based on thinkphp6, with one click curd and other functions
Set JTAG fuc invalid to normal IO port
NLP literature reading summary
Valentine's Day is coming! Without 50W bride price, my girlfriend was forcibly dragged away...
手写简易版flexible.js以及源码分析
大学阶段总结
[MySQL transaction]
The number of patent applications in China has again surpassed that of the United States and Japan, ranking first in the world for 11 consecutive years
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
[web security] nodejs prototype chain pollution analysis
随机推荐
Book list | as the technical support Party of the Winter Olympics, Alibaba cloud's technology is written in these books!
Finishing (III) - Exercise 2
Life planning (flag)
win10微软拼音输入法输入文字时候下方不出现中文提示
【FreeRTOS】FreeRTOS學習筆記(7)— 手寫FreeRTOS雙向鏈錶/源碼分析
com. alibaba. nacos. api. exception. NacosException
电子协会 C语言 1级 34 、分段函数
Chain ide -- the infrastructure of the metauniverse
The important role of host reinforcement concept in medical industry
节点基础~节点操作
Mysql database - function constraint multi table query transaction
Routing decorator of tornado project
Basic DOS commands
Crawler (III) crawling house prices in Tianjin
Practice (9-12 Lectures)
Used on windows Bat file startup project
Guoguo took you to write a linked list, and the primary school students said it was good after reading it
With excellent strength, wangchain technology, together with IBM and Huawei, has entered the annual contribution list of "super ledger"!
[network security] what is emergency response? What indicators should you pay attention to in emergency response?
Improve the accuracy of 3D reconstruction of complex scenes | segmentation of UAV Remote Sensing Images Based on paddleseg