Leetcode 633 Sum of Square Numbers

来源:互联网 发布:c语言栈实现四则运算 编辑:程序博客网 时间:2024/06/11 11:52

Leetcode 633 Sum of Square Numbers

#include <math.h>class Solution {public:    bool judgeSquareSum(int c) {    for(int i = 0;i <= (int)sqrt(c);i++)    {        double tmp = c - i * i;        if(sqrt(tmp) == (int)sqrt(tmp))//only two numbers' square sum          return true;    }    return false;    }};
原创粉丝点击