#!/bin/bash
read -p "请输入一组数字:" -a array
accumulate=1
for num in ${array[@]}
do
accumulate=$(( $accumulate * num))
done
echo "乘积是:" $accumulate
计算读入的一组数字(在同一行输入)的积
#!/bin/bash
read -p "请输入一组数字:" -a array
accumulate=1
for num in ${array[@]}
do
accumulate=$(( $accumulate * num))
done
echo "乘积是:" $accumulate
计算读入的一组数字(在同一行输入)的积