#!/bin/bash
echo "nhap 3 so a,b,c: "
read a
read b
read c
delta=$(echo "$b*$b-4*$a*$c" | bc)
if [ $delta -lt 0 ]; then
echo "phuong trinh vo nghiem"
elif [ $delta -eq 0 ]; then
echo -n "phuong trinh co nghiem kep x= "
x=$(echo "scale=2; -($b)/(2*$a)" | bc)
echo "$x"
else
echo "phuong trinh co 2 nghiem phan biet: "
x1=$(echo "scale=2; -($b + sqrt($delta))/(2*$a)" | bc)
x2=$(echo "scale=2; -($b - sqrt($delta))/(2*$a)" | bc)
echo "x1=$x1"
echo "x2=$x2"
fi
exit 0
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment