当前位置:网站首页>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
边栏推荐
- Matlab to find the limit
- ArcGIS中对面状河流进行等距分段【渐变赋色、污染物扩散】
- Memorized Function
- 商品搜索引擎—推荐系统设计
- Aes-128-cbc-pkcs7padding encrypted PHP instance
- C语言的指针详解
- B+树|MYSQL索引使用原则
- C # output the middle order traversal through the clue binary tree
- Golang image/png 处理图片 旋转 写入
- Server monitoring netdata panel configuring mail service
猜你喜欢

Leetcode game 299

C语言内存函数

Server monitoring netdata panel configuring mail service

力扣:合并两个有序链表

CVPR2022 | 通过目标感知Transformer进行知识蒸馏

Comparison table of LR and Cr button batteries

mysql调优

File contained log poisoning (user agent)

qt 自定义控件 :取值范围

The role of each part of Neural Network & thoroughly understand neural network
随机推荐
NvtBack
Cvpr2022 𞓜 future transformer with long-term action expectation
YOLO系列梳理(九)初尝新鲜出炉的YOLOv6
趣谈网络协议(二)传输层
C#线索二叉树的定义
AcWing第57场周赛
Interesting talk on network protocol (II) transport layer
Definition of C # clue binary tree
倍福TwinCAT配置、调试第三方伺服详细讲解--以汇川IS620N为例子
C#通过中序遍历对二叉树进行线索化
AcWing 234 放弃测试
C#实现二叉树的先序遍历、中序遍历、后序遍历
C#实现队列结构定义、入队、出队操作
倍福PLC通过CANOpen通信控制伺服
C#实现二叉树非递归中序遍历程序
如果我在深圳,到哪里开户比较好?另外想问,现在在线开户安全么?
AES-128-CBC-Pkcs7Padding加密PHP实例
Netdata data data persistence configuration
Clickhouse database uses JDBC to store milliseconds and nanoseconds
Tutorial on building pytoch model from zero (V) writing training process -- some basic configurations