Linux脚本——打印口算题

#!/bin/bash

function print_random() {
    # for k in {1..10};
    # do
    #     echo -e "$k \t $RANDOM"
    # done

    min=$1
    max=$(($2-$min+1))
    num=$(date +%s%N)
    echo $(($num%$max+$min))
    # if [ $? ]; then
    #     return 0
    # else
    #     return 1
    # fi
}



for i in {1..25};
do
    for j in {1..1};
    do
        rnd1=$(print_random 500 1000)
        rnd2=$(print_random 100 499)
        rnd3=$(print_random 50 100)
        rnd4=$(print_random 1 9)
        rnd5=$(print_random 500 1000)
        rnd6=$(print_random 100 499)
        rnd7=$(print_random 1 10)
        rnd8=$(print_random 1 10)

        # let "random_nu = $rnd1 + $rnd2"
        # echo "$rnd1 + $rnd2 = $random_nu"
        echo -e "$rnd1 + $rnd2 =\\t\\t\\t\\c" >> caculation1.txt
        echo -e "$rnd3 ÷ $rnd4 =\\t\\t\\t\\c" >> caculation1.txt
        echo -e "$rnd5 - $rnd6 =\\t\\t\\t\\c" >> caculation1.txt
        echo -e "$rnd7 x $rnd8 =\\t\\t\\t\\c" >> caculation1.txt
    done
    echo -e "\\n\\n\\n\\n" >> caculation1.txt
done

 

posted on 2024-05-07 23:26  gkhost  阅读(11)  评论(0编辑  收藏  举报

导航