Notice
Recent Posts
Recent Comments
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
Tags more
Archives
Today
Total
관리 메뉴

Share Garam's everyday life.

소수 만들기 본문

알고리즘

소수 만들기

가람스나이퍼님 (Joshua_Choi_Brother) 2021. 4. 21. 01:26

#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
bool checkSoSu(int n){
    int i=n-1;
    while(i!=1){
        if(n%i==0){
            return false;
        }
        else i--;
    }
    
    return true;
}
// nums_len은 배열 nums의 길이입니다.
int solution(int nums[], size_t nums_len) {
    int answer = 0;
    for(int i=0;i<nums_len-2;i++){
        for(int j=i+1;j<nums_len-1;j++){
            for(int k=j+1;k<nums;k++){
                if(checkSoSu(nums[i]+nums[j]+nums[k]))
                    answer++;
            }
        }
    }
    
    return answer;
}

'알고리즘' 카테고리의 다른 글

내적  (0) 2021.04.21
3진법 뒤집기  (0) 2021.04.21
가운데 글자 가져오기  (0) 2021.04.21
알고리즘1  (0) 2018.03.17
아 포인터 모르네..  (0) 2018.03.16