当前位置:网站首页>L1-027 rental (Lua)
L1-027 rental (Lua)
2022-07-07 19:20:00 【Just be interesting】
subject
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};
Code
local arr = {
}
local s = io.read()
for i = 1, #s do
idx = tonumber(s:sub(i, i))
arr[idx] = 1
end
local s1, s2 = "int[] arr = new int[]{", "int[] index = new int[]{"
local map = {
}
local len = 0
for i = 9, 0, -1 do
if arr[i] then
map[i] = len
len = len + 1
s1 = s1 .. i .. ","
end
end
s1 = s1:sub(1, #s1 - 1) .. "};"
for i = 1, #s do
s2 = s2 .. map[tonumber(s:sub(i, i))] .. ","
end
s2 = s2:sub(1, #s2 - 1) .. "};"
print(s1)
print(s2)
边栏推荐
- The top of slashdata developer tool is up to you!!!
- 3.关于cookie
- 解决rosdep的报错问题
- Multimodal point cloud fusion and visual location based on image and laser
- Redis
- L1-023 output gplt (Lua)
- POJ 2392 Space Elevator
- Tips and tricks of image segmentation summarized from 39 Kabul competitions
- 杰理之开机自动配对【篇】
- [Base64 notes] [suggestions collection]
猜你喜欢

Scientists have observed for the first time that the "electron vortex" helps to design more efficient electronic products

Do you know all four common cache modes?

如何选择合适的自动化测试工具?

数据验证框架 Apache BVal 再使用

5billion, another master fund was born in Fujian

6. About JWT

杰理之关于 TWS 声道配置【篇】

Redis

SD_ DATA_ RECEIVE_ SHIFT_ REGISTER

Numpy——axis
随机推荐
For friends who are not fat at all, nature tells you the reason: it is a genetic mutation
PV static creation and dynamic creation
ip netns 命令(备忘)
unity2d的Rigidbody2D的MovePosition函数移动时人物或屏幕抖动问题解决
[Blue Bridge Cup training 100 questions] sort scratch from small to large. Blue Bridge Cup scratch competition special prediction programming question centralized training simulation exercise question
前首富,沉迷种田
Solve the error reporting problem of rosdep
Redis
I feel cheated. Wechat tests the function of "size number" internally, and two wechat can be registered with the same mobile number
Scientists have observed for the first time that the "electron vortex" helps to design more efficient electronic products
6. About JWT
App capture of charles+postern
Redis publishing and subscription
Uvalive – 4621 CAV greed + analysis "suggestions collection"
AI writes a poem
2022.07.05
手把手教姐姐写消息队列
PTA 1102 teaching Super Champion volume
2022.07.02
初识缓存以及ehcache初体验「建议收藏」