Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
Cs699_A1
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Sarvesh
Cs699_A1
Commits
478105fe
Commit
478105fe
authored
Aug 26, 2020
by
Sarvesh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload new file
parent
02aa29ad
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
codingmonks/q4/q4.sh
codingmonks/q4/q4.sh
+28
-0
No files found.
codingmonks/q4/q4.sh
0 → 100644
View file @
478105fe
#!/usr/bin/bash
grep
-oP
'\S+'
q4_in.txt
>
col.txt
sort
-n
col.txt
>
sorted.txt
i
=
0
sum
=
0
nums
=
$(
<sorted.txt
)
array[0]
=
0
for
n
in
$nums
;
do
sum
=
$((
sum
+
n
))
i
=
$((
i+1
))
array[
$i
]=
$n
done
echo
"Mean="
$(
echo
"scale=3;(
$sum
/
$i
)"
| bc
)
#echo ${array[*]} array
if
[
$((
$i
%
2
))
-ne
0
]
then
middle
=
$[
$((
i/2
))
+1]
echo
"Median="
${
array
[
$middle
]
}
else
ind1
=
$((
$i
/
2
))
ind2
=
$((
ind1+1
))
num1
=
${
array
[
$ind1
]
}
num2
=
${
array
[
$ind2
]
}
final
=
$((
num1+num2
))
echo
"Median="
$(
echo
"scale=3;(
$final
/2)"
| bc
)
fi
rm
sorted.txt
rm
col.txt
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment