Contents

Views 8863 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
369 System/OS [linux] wget 명령 사용 예제 hooni 2020.05.26 1434
368 System/OS [linux] Xwindow/Xmanager 사용 hooni 2003.04.23 13334
367 System/OS [linux] X환경 GNOME에서 KDE로 바꾸는 법.. hooni 2013.04.23 12365
366 System/OS [linux] yum 업데이트 시 커널 제외하기 hooni 2014.09.11 1258
365 System/OS [linux] 간단한 find 명령어 설명(업데이트 해야 함) hooni 2013.04.23 9111
364 System/OS [linux] 간단한 NAT 설정 script hooni 2003.04.23 12597
363 System/OS [linux] 간단한 vi편집기 사용 명령 hooni 2003.04.23 13456
362 System/OS [linux] 계정관리하기(내공쌓기) hooni 2003.04.23 13157
361 System/OS [linux] 기본 명령어 (내공쌓기) hooni 2003.04.23 14333
360 System/OS [linux] 기본적인 설정하기(내공쌓기) hooni 2003.04.23 13993
359 System/OS [linux] 기존 환경설정 저장하면서 커널 컴파일.. hooni 2003.04.23 13458
358 System/OS [linux] 꿀통(honeyd) 설치하기.. 메뉴얼 과정 6 file hooni 2006.04.23 20219
Board Pagination Prev 1 ... 63 64 65 66 67 68 69 70 71 72 ... 98 Next
/ 98