본문 바로가기
C++

[프로그래머스] 제곱수 판별하기

by 띰쥬 2025. 9. 4.
728x90
반응형
SMALL

#include <string>
#include <cmath>

using namespace std;

int solution(int n) {
    
    double sqr_d = sqrt(n);
    int sqr_i = static_cast<int>(sqr_d);
    
    if(sqr_i==sqr_d)
        return 1;
    else
        return 2;
}

728x90
반응형
LIST

댓글