出处:http://www.dewen.org/q/620
#includeint judge(int num){ int min = 1; if(num < 0) { return 0; } else if(num == 0 || num == 1) { return 1; } else { int current = 2; while(1) { if(current * current < num) { min = current; current = min * 2; } else if(current * current == num) { return 1; } else if(current > min + 1) { current = ((min+current)) / 2; } else { return 0; } printf("%d", current); } }}int main(){ printf("%d", judge(8));}