#!/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
Related Posts
[shell scripts] tim kiem file
25 Aug 20130#!/bin/bash echo -n "nhap file can tim kiem: " read file name_file=$(find / -name $file) echo "ket ...Read more »
[shell scripts] Tinh tổng S=1+2+3+...+n
25 Aug 20130#!/bin/bash echo "nhap n tu ban phim: " read n s=0 for ((i=1; i<=$n; i++)) do let s=s+1 done echo...Read more »
[shell scripts] Tìm mã trên dãy số
25 Aug 20130#!/bin/bash echo -n "nhap n: " read n for ((i=0; i<n; i++)) do read -p "a[$i]= " a[$i] done...Read more »
[shell scripts] Scripts kiểm tra %CPU và %MEM
25 Aug 20131#!/bin/bash # %CPU a=$(ps -eo pcpu | awk '{tongcpu+=$1} END {print tongcpu}') echo "tong % CPU la: $...Read more »
[shell scipts] 1 số bài tập AWK đơn giản
25 Aug 20130bai 1: su dung awk in tat ca file /etc/passwd awk '{print}' /etc/passwd hoac co the viet awk '{print...Read more »
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment
Click to see the code!
To insert emoticon you must added at least one space before the code.