嵌入式学习——C高级

笔记

作业 

        1. 输入两个数,实现两个数的排序。(shell脚本)

 #!/bin/bash
  
 function fun()
 {
     tmp=${arr[0]}
     arr[0]=${arr[1]}
     arr[1]=$tmp
 }
 
 read -p "please enter two number:" -a a
 if ((arr[0]>arr[1]))
 then
 #   tmp=${arr[0]}
 #   arr[0]=${arr[1]}                   
 #   arr[1]=$tmp
     fun
     echo ${arr[0]} ${arr[1]}
 else
     echo ${arr[0]} ${arr[1]}
 fi

        2. 输入一个数,计算是否是水仙花。(shell脚本)

#!/bin/bash

read -p "please enter a number:" num
if ((num > 99 && num < 999 && (num%10)**3+(num/10%10)**3+(num/100)**3==num))
then
    echo yes
else
    echo no
fi

        3. 输入一个成绩实现登记判断 90-100A、80-89B、70-79C、60-69D、0-59E。(shell脚本)

#!/bin/bash
 
read -p "please enter score: " score
if ((score<=100 && score>=90))
then
    echo A
elif ((score<90 && score>=80))
then
    echo B
elif ((score<80 && score>=70))
then
    echo C
elif ((score<70 && score>=60))
then
    echo D
elif ((score<60 && score>=0))                                                       
then
    echo E
else
    echo score input error
fi

相关推荐

  1. 嵌入学习63-C++

    2024-04-28 22:38:01       33 阅读
  2. 怎样学习嵌入C语言编程

    2024-04-28 22:38:01       71 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-28 22:38:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-28 22:38:01       100 阅读
  3. 在Django里面运行非项目文件

    2024-04-28 22:38:01       82 阅读
  4. Python语言-面向对象

    2024-04-28 22:38:01       91 阅读

热门阅读

  1. Termux推送本地文件到GitHub仓库

    2024-04-28 22:38:01       33 阅读
  2. Spring配置文件敏感数据加密

    2024-04-28 22:38:01       30 阅读
  3. 一个简单的springcloud案例

    2024-04-28 22:38:01       30 阅读
  4. git .gitignore忽略非必要文件提交

    2024-04-28 22:38:01       30 阅读
  5. 学习Python的第二天:深化理解,编程实践

    2024-04-28 22:38:01       34 阅读
  6. c++代码规范整理

    2024-04-28 22:38:01       29 阅读
  7. 前端面试题大合集2----基础篇

    2024-04-28 22:38:01       24 阅读
  8. Learning to Upsample by Learning to Sample

    2024-04-28 22:38:01       25 阅读