Leetcode的簡單算法題:69. x 的平方根

鏈接:https://leetcode.cn/problems/sqrtx/

我的代碼

int mySqrt(int x){
    long res=0,i;
    for(i=1;i<=x;i++){
        if(i*i>x){
            break;
        }
    }
    res=i-1;
    return res;
}

提交結果

提交結果 執行用時 內存消耗 語言 提交時間 備註
通過
20 ms 5.4 MB C 2022/07/01 15:09

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章