367. Valid Perfect Square

Given a positive integer num, write a function which returns True if num is a perfect square else False.

题目含义:判断一个数能否被开方

1     public boolean isPerfectSquare(int num) {
2         for (int i = 1; i <= num / i; ++i) {
3             if (i * i == num) return true;
4         }
5         return false;        
6     }

 

posted @ 2017-10-20 20:39  daniel456  阅读(82)  评论(0编辑  收藏  举报