메뉴 건너뛰기

app

조합 구하기.

박영식2002.06.14 17:10조회 수 2574댓글 0

    • 글자 크기
음. 부함수로 짰고. 재귀함수가 아님.
int 형이라 8이상을 입력하면 안 됨.
파일 2는 long형이고, call by reference로 하향식임.
#include <stdio.h>
int gop(int n);
void main()
{
        int x,y;
        int i,j,k;
        printf("This program is combinationn");
        printf("first, input n = ");
        scanf("%d",&x);
        printf("next, input r = ");
        scanf("%d",&y);
        i=gop(x);/*n!*/
        j=gop(y);/*r!*/
        k=gop(x-y);/*(n-r)!*/
        printf("        printf("n%d %d
}
int gop(int n)
{
        int a,res=1;
        for(a=n;a>0;a--)
                 res*=a;
        return(res);
}
박영식 (비회원)
    • 글자 크기

댓글 달기

이전 1 2 3 4 5 6 7 8 9 10... 14다음
첨부 (0)
위로