#!/bin/bash
h=0
l=0
n=0
reads=0
divider=6
while read user_input; do
((reads++))
[ "$user_input" -eq 1 ] && ((l++))
[ "$user_input" -eq 2 ] && ((n++))
[ "$user_input" -eq 3 ] && ((h--))
if [ "$((reads%52))" -eq 0 -a "$divider" -gt 1 ]; then
((divider--))
fi
echo " True Count $(($((h+l))/divider)) High cards $h/120 Null Cards $n/72 Low Cards $l/120"
done
답변1
이것을 사용해 보세요.기원전
#!/bin/bash
h=0
l=0
reads=0
divider=6
while read user_input; do
((reads++))
((user_input == 1 && h++))
((user_input == 2 && n++))
((user_input == 3 && h--))
if ((reads%52 == 0 && divider > 1)); then
((divider--))
fi
echo "True Count $(bc <<< "scale=3; ($h+$l)/$divider") High cards $h/120 Null Cards $n/72 Low Cards $l/120"
done