当前位置:网站首页>Write a shell script to find the "reverse order" of a number“
Write a shell script to find the "reverse order" of a number“
2022-06-29 13:20:00 【Xiaotiantian 666】
In an arrangement , If the front and back positions of a logarithm are in reverse order of magnitude , That is, the number in front is greater than the number in the back , Then they are called a reverse order . The total number in reverse order in an arrangement is called the number in reverse order of the arrangement . in other words , about n A different element , First, there is a standard order between the elements ( for example n individual Different natural numbers , The standard order can be set from small to large ), So here it is n In any arrangement of elements , When the actual order of two elements is different from the standard order , That's all 1 In reverse order . The total number of all the inverses in an arrangement is called the reverse number of the permutation .
Such as 2431 in ,21,43,41,31 It's in reverse order , The reverse number is 4.
#!/bin/bash
echo -n Please enter a number :
read n
count=0 # Used to record the number in reverse order
while [ $n -gt 0 ]
do
n1=`expr $n % 10` # Get the number of bits
n2=`expr $n / 10` # Get other numbers except bits
n=$n2
# One by one, it is better than the past
while [ $n2 -gt 0 ]
do
n3=`expr $n2 % 10`
n2=`expr $n2 / 10`
if [ $n1 -lt $n3 ]
then
count=`expr $count + 1`
fi
done
done
echo The reverse order of this number is :$count
边栏推荐
- 服务器上的RTC时间与世界时间不一致解决办法
- 神经网络各个部分的作用 & 彻底理解神经网络
- 超 Nice 的表格响应式布局小技巧
- UI file introduction in QT
- Cvpr2022 | reexamine pooling: your receptive field is not the best
- C # realizes the first order traversal, middle order traversal and second order traversal of binary tree
- Cvpr2022 | panopticdepth: a unified framework for depth aware panoramic segmentation
- Server monitoring netdata panel configuring mail service
- 记一次固态更新与系统迁移debug的过程
- Force buckle: merging two ordered linked lists
猜你喜欢

三维模型下载与动画控制

CVPR2022 | PanopticDepth:深度感知全景分割的统一框架

从零搭建Pytorch模型教程(四)编写训练过程--参数解析

QT signal and slot

超 Nice 的表格响应式布局小技巧

CVPR2022 | 可精简域适应

Schiederwerk Power Supply repair smps12 / 50 pfc3800 Analysis

RT thread memory management

CVPR2022 | A ConvNet for the 2020s & 如何设计神经网络总结
![Equidistant segmentation of surface rivers in ArcGIS [gradient coloring, pollutant diffusion]](/img/05/18fb41f78b9b57175d50dfece65535.png)
Equidistant segmentation of surface rivers in ArcGIS [gradient coloring, pollutant diffusion]
随机推荐
倍福控制器连接松下EtherCAT伺服注意事项
C#实现顺序表定义、插入、删除、查找操作
Beifu PLC controls servo through CANopen communication
Acwing 234 abandoning testing
Comparison table of LR and Cr button batteries
C binary tree structure definition and node value addition
商品搜索引擎—推荐系统设计
If I am in Shenzhen, where can I open an account? In addition, is it safe to open an account online now?
C # clue binary tree through middle order traversal
Another "provincial capital university", coming!
360数科新能源专项产品规模突破60亿
PyGame accurately detects image collision
Tutorial on building pytoch model from zero (IV) compiling training process -- Parameter Analysis
力扣:合并两个有序链表
Pod security policy (PSP)
服务器上的RTC时间与世界时间不一致解决办法
Async principle implementation
CVPR2022 | 可精简域适应
Equidistant segmentation of surface rivers in ArcGIS [gradient coloring, pollutant diffusion]
C#线索二叉树的定义