#!/bin/bash
MAXTHROWS=$1
HEADS=0
TAILS=0
throw=0
print_result(){
echo the HEADS = $HEADS
echo the TAILS = $TAILS
echo
}
update_count(){
case $1 in
0)let " HEADS += 1";;
1)let " TAILS += 1" ;;
esac
}
echo
while [ "$throw" -lt "$MAXTHROWS" ]
do
let "coin = $RANDOM % 2 "
update_count $coin
let "throw += 1"
done
print_result
阅读(1575) | 评论(0) | 转发(0) |