update
This commit is contained in:
parent
1f1ad49427
commit
6f050a029e
2496 changed files with 37609 additions and 3031 deletions
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
int icmp(const void *a, const void *b)
|
||||
{
|
||||
return *(int*)a < *(int*)b ? -1 : *(int*)a > *(int*)b;
|
||||
return *(const int*)a < *(const int*)b ? -1 : *(const int*)a > *(const int*)b;
|
||||
}
|
||||
|
||||
void leaf_plot(int *x, int len)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ void main() {
|
|||
int[][int] histo;
|
||||
foreach (x; data)
|
||||
histo[x / 10] ~= x % 10;
|
||||
immutable loHi = reduce!(min, max)(data);
|
||||
immutable loHi = data.reduce!(min, max);
|
||||
foreach (i; loHi[0]/10 .. loHi[1]/10 + 1)
|
||||
writefln("%2d | %(%d %) ", i, histo.get(i, []).sort());
|
||||
}
|
||||
|
|
|
|||
10
Task/Stem-and-leaf-plot/Racket/stem-and-leaf-plot.rkt
Normal file
10
Task/Stem-and-leaf-plot/Racket/stem-and-leaf-plot.rkt
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#lang racket
|
||||
(define (show-stem+leaf data)
|
||||
(define xs (sort data <))
|
||||
(for ([stem (add1 (floor (/ (last xs) 10)))])
|
||||
(printf "~a|" (~a #:width 2 #:align 'right stem))
|
||||
(for ([i xs])
|
||||
(define-values [q r] (quotient/remainder i 10))
|
||||
(when (= q stem) (printf " ~a" r)))
|
||||
(newline)))
|
||||
(show-stem+leaf (sequence->list (in-producer read eof)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue