S10 Day 1: Quartiles

1 개요[ | ]

Day 1: Quartiles
1일차: 사분위수
해커랭크 10 Days of Statistics
문제 C C++ C# Go Java node.js Perl PHP Python R Ruby
0-1 Day e
S10 Day 0: Mean, Median, and Mode
S10 Day 0: Weighted Mean
S10 Day 1: Quartiles
S10 Day 1: Interquartile Range
S10 Day 1: Standard Deviation

2 R[ | ]

a = scan("stdin")
n = a[1]
x = a[2:(n+1)]
m = median(x)
q1 = median(x[x<m])
q3 = median(x[x>m])
cat( q1, "\n" )
cat( m, "\n" )
cat( q3, "\n" )
a = scan("stdin")
n = a[1]
x = a[2:(n+1)]
x = sort(x)
lowers = x[1:floor(n/2)]
uppers = x[ceiling(n/2)+1:floor(n/2)]
q1 = median(lowers)
m = median(x)
q3 = median(uppers)
cat( q1, "\n" )
cat( m, "\n" )
cat( q3, "\n" )
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}