Contents

Views 8904 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
1041 System/OS [linux] 리눅스, 유닉스 CPU 이용률 확인.. hooni 2013.04.23 23865
1040 Develop [c] 다중연결 서버 만들기 #4 - thread 사용 file hooni 2013.04.23 23757
1039 Develop [c#] 비동기 통신 샘플 코드 ㅎㅎ file hooni 2013.04.23 23699
1038 PPT [ppt] 뚜레쥬르 온라인 마케팅 제안서 file hooni 2013.04.23 23554
1037 Develop GCM 사용하기 2 (단말에 GCM 구현하기) file hooni 2013.07.06 23418
1036 Etc [ios] 아이폰 개발 따라하기 ㅋㅋㅋ hooni 2013.04.23 23349
1035 Algorithm 러시아 페인트공 알고리즘에 대해.. hooni 2013.04.23 22990
1034 Develop [ios] UIColor 지정에서 RGB define ㅎㅎ hooni 2013.04.23 22971
1033 Develop [js] 자바스크립트(Javascript) 코드를 동적으로 삽입하는 방법.. file hooni 2013.04.23 22936
1032 Develop [ios] UILabel top alignㅎㅎ hooni 2013.04.23 22895
1031 PPT [doc] 정보보호이론 강의자료 (중앙대꺼..) 2 file hooni 2013.04.23 22885
1030 Develop 밸런싱 로봇.. 최종.. (관련 논문도 첨부) ㅋㅋ file hooni 2013.04.23 22881
Board Pagination Prev 1 ... 7 8 9 10 11 12 13 14 15 16 ... 98 Next
/ 98