当前位置:网站首页>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
边栏推荐
猜你喜欢

Cvpr2022 𞓜 loss problem in weakly supervised multi label classification

leetcode 第 299场周赛

QT custom control: value range

LR、CR纽扣电池对照表

OPC of Beifu twincat3_ UA communication test case

服务器监控netdata面板配置邮件服务

别再重复造轮子了,推荐使用 Google Guava 开源工具类库,真心强大!

Interesting talk on network protocol (II) transport layer

3D model downloading and animation control

Leetcode game 299
随机推荐
LR、CR纽扣电池对照表
3D model downloading and animation control
项目管理复习题
PyGame accurately detects image collision
记一次固态更新与系统迁移debug的过程
mysql调优
别再重复造轮子了,推荐使用 Google Guava 开源工具类库,真心强大!
C # implements definition, insertion and construction of binary sort tree
Install the terrain ovirt plug-in to provide automated management for ovirt
Ordinary users use vscode to log in to SSH and edit the root file
Cvpr2022 𞓜 thin domain adaptation
Another "provincial capital university", coming!
NvtBack
C语言模拟实现所有字符函数
MySQL常用语句和命令汇总
Tutorial on building pytoch model from zero (V) writing training process -- some basic configurations
C # realizes the first order traversal, middle order traversal and second order traversal of binary tree
Hutool tool class learning (continuous update)
强大、优秀的文件管理软件评测:图片管理、书籍管理、文献管理
从Mpx资源构建优化看splitChunks代码分割