Views 8863 Votes 0 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
# 약수 구하는 알고리즘..
#include<stdio.h>

void main()
{
    int i, j, n, m;

    scanf("%d", &n);
    for(i=1 ; i         j = n / i;
        m = j * i;
        if( !(n-m) ) printf("%d ", i);
    }
}


# 최대 공약수 구하는 알고리즘 (유클릿 알고리즘)
#include<stdio.h>

int gcd(int m, int n)
{
    if (m<=0) return 0;
    if (n<=0) return 0;
    while(m != n){
        if (m>n) m = m - n;
        else n = n - m;
    }
    return n;
}

void main()
{
    int a,b;

    printf("Enter a first Number : ");
    scanf("%d",&a);

    printf("Enter a second Number : ");
    scanf("%d",&b);

    printf("GCD is %d",gcd(a,b));
    getch();
}


# 완전수 구하는 알고리즘
완전수란 자신을 제외한 약수의 합과 같은 양의 정수를 말한다.
#include<stdio.h>

void main()
{
    int i, j, n, m, sum;

    for(n=0; n<500; n++)
    {
        sum=0;
        for(i=1 ; i             j = n / i;
            m = j * i;
            if( !(n-m) ){
                //printf("%d ", i);
                sum+=i;
            }
        }

        if(n==sum) printf("n%d is Perfact!n", n);
        //else printf("n%d is Not! (%d!=%d)n", n, sum, n);
    }
}


?

List of Articles
No. Category Subject Author Date Views
153 Develop [c++] 트리컨트롤 스텝 3 예제.. file hooni 2013.04.23 7945
152 Develop [c++] 트리컨트롤 스텝 2 예제.. file hooni 2013.04.23 6955
151 Develop [c++] 템플릿(Template) 예제 소스.. file hooni 2013.04.23 6978
150 Develop [c++] 초간단 스택 두 가지 방식(class, struct) file hooni 2013.04.23 7553
149 Develop [c++] 채팅로봇 소스.. ㅋㄷㅋㄷ file hooni 2013.04.23 8878
148 Develop [c++] 중복실행 방지(Mutex;뮤텍스 ) 샘플 소스.. ㅋㅋ file hooni 2013.04.23 8737
147 Develop [c++] 자료구조(링크리스트,스택,큐)와 후위 표기 계산기 샘플 ㅋㅋ 4 file hooni 2013.04.23 12318
146 Develop [c++] 인라인 함수에 대한 설명 hooni 2013.04.23 7110
145 Develop [c++] 인라인 함수 설명과 예제.. file hooni 2013.04.23 6633
144 Develop [c++] 윈도우 프로세스뷰어 분석.. ㅋㅋ file hooni 2013.04.23 8836
143 Develop [c++] 윈도우 API 정복 예제 file hooni 2013.04.23 7608
142 Develop [c++] 웹폼(webform)전송과 http 파일 업로드 샘플 file hooni 2013.04.23 33070
141 Develop [c++] 압축프로그램(Lite Zip) 샘플 file hooni 2013.04.23 8603
140 Develop [c++] 쓰레드(Thread) 객체의 사용 hooni 2013.04.23 8576
139 Develop [c++] 소켓 프로그래밍 관련 링크.. (퍼올려고 올린거) hooni 2013.04.23 7029
138 Develop [c++] 바탕화면 테두리에 자석처럼 붙는 스냅효과.. file hooni 2013.04.23 8902
Board Pagination Prev 1 ... 42 43 44 45 46 ... 53 Next
/ 53