[프로그래머스/C++]Lv.0 - 순서쌍의 개수

YH J·2023년 4월 19일
0

프로그래머스

목록 보기
58/168

문제 링크

https://school.programmers.co.kr/learn/courses/30/lessons/120836

내 풀이

1부터 순서대로 쭉 가면서 나누어 떨어지는 숫자가 있으면 answer++한다.

내 코드

#include <string>
#include <vector>

using namespace std;

int solution(int n) {
    int answer = 0;
    
    for(int i = 1; i <= n; i++)
    {
        if(n%i == 0)
            answer++;
    }
    
    return answer;
}

다른 사람의 풀이

#include <string>
#include <vector>

using namespace std;

int solution(int n)
{
    int answer=0;
    for(int i=1; i<=n; i++)
        if(n%i==0) answer++;
    return answer;
}

다른 사람의 풀이 해석

같은 풀이이다.

profile
게임 개발자 지망생

0개의 댓글