快手Python笔试题【杭州多测师】【杭州多测师_王sir】

 

 

二分查找法:
def t(arr, target):
    left, right = 0, len(arr) - 1
    while left <= right:
        mid = left + (right - left) // 2
        if arr[mid] == target:
            return mid  
        elif arr[mid] < target:
            left = mid + 1  
        else:
            right = mid - 1  
    return -1 

arr = [2, 5, 8, 12, 16, 23, 38, 56, 72, 91]
target = 23

  

def test():
    for i in range(10):
        if i % 2 !=0:
            print("hello world")
        else:
            pass
test() #调用函数
package com.duoceshi.thread;

public class HelloWorld {

    public static void test(){
        for (int i = 0; i < 10 ; i++) {
            if (i % 2 == 0){
                continue;
            }else{
                System.out.println("hello world");
            }
        }
    }

    public static void main(String[] args) {
        HelloWorld.test();
    }
}

 

posted @ 2022-09-29 19:54  多测师_树哥  阅读(67)  评论(0)    收藏  举报