Comment detail

急勾配の判定 (Nested Flatten)

後ろから反復してみました。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#module

#define true  1
#define false 0

#defcfunc IsSteepSlope array arr,  \
    local size, local nowSum, local bResult
    
    size    = length(arr)
    nowSum  = 0
    bResult = true
    
    repeat size, 1
        if ( cnt == 1 || nowSum < arr(size - cnt) ) {
            nowSum += arr(size - cnt)
            
        } else {
            bResult = false
            break
        }
    loop
    
    return bResult
    
#global

    list = 128, 64, 32, 16, 8, 4
    mes IsSteepSlope(list)
    stop

Index

Feed

Other

Link

Pathtraq

loading...