leetcode633+判断一个数是否为两个数的平方和

https://leetcode.com/problems/sum-of-square-numbers/description/

class Solution {
public:
    bool judgeSquareSum(int c) {
        int limit = sqrt(c);
        for(int i=0; i<=limit; i++){
            double test = sqrt(c-i*i);
            if(test- int(test)==0) return true;
        }
        return false;
    }
};

 

你可能感兴趣的:(Leetcode)