static boolean search(int [] t, int k) { int low = 0 ; int high = t.length ; while (low < high) { int m = (low+high) / 2 ; if (k < t[m]) { high = m ; } else if (k > t[m]) { low = m+1 ; } else { return true ; } } return false ; } |
φ(i,j) = | ( | k ∈ t[0...n[ ⇒ k ∈ t[i...j[ | ) |
static boolean searchBis(int [] t, int k) { int low = -1 ; int high = t.length ; // t[low] < k ≤ t[high] while (high-low > 1) { int m = (low+high)/2 ; if (t[m] < k) { low = m ; } else high = m ; } // high = low+1 ∧ t[low] < k ≤ t[high] return high < t.length && t[high] == k ; } |
static int f(int x) { int r ; if (x > 100) r = x-10 ; else r = f(f(x+11)) ; return r ; } |
static int f(int x) { int r ; // ∀ x. P(x,f(x)) if (x > 100) { r = x-10 ; } else { r = f(f(x+11)) ; } // P(x,r) return r ; } |
Ce document a été traduit de LATEX par HEVEA et HACHA.