Commit e645f14b authored by Keshav Agarwal's avatar Keshav Agarwal

week2 q4 and readme changes

parent bd7faddc
Members:
Aditya Aditya
Keshav Agarwal
Mahesh
Vishal Mishra
\ No newline at end of file
Keshav - Q1
Mahesh - Q2
Aditya - Q3
Vishal - Q4
GIT: https://git.cse.iitb.ac.in/keshavagarwal/unagi/tree/master/week2
References:
https://www.tutorialspoint.com/unix/unix-special-variables.htm
https://stackoverflow.com/questions/1975849/how-to-split-a-line-into-words-separated-by-one-or-more-spaces-in-bash
\ No newline at end of file
......@@ -2,18 +2,19 @@
sums=0
counts=0
arr=()
sort q4_in.txt > tem.txt
xargs -n1 < q4_in.txt | sort -n > tem.txt
while read p
do
arr[counts]=$p
counts=`expr $counts + 1`
sums=`expr $sums + $p`
done < tem.txt
echo `expr $sums / $counts`
echo `echo "$sums / $counts" | bc -l`
rem=$(( $counts % 2 ))
if [ $rem -eq 0 ]
then
echo "$(( ( arr[$(($counts/2))] + arr[$(($counts/2-1))] ) / 2 ))"
mid=$((arr[$(($counts/2))] + arr[$(($counts/2-1))]))
echo `echo "$mid / 2" |bc -l`
else
echo "${arr[$counts /2]}"
fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment