반응형
#include <stdio.h>  
int fac(int); 
int main() 
{ 
  int i; 
  for(i=1; i<=5; i++){
  	printf(" %d ",fac(i)); 
  } 
  int fac(int a) 
  { 
    int i; 
    int f=1; 
  for(i=1; i<=a; i++) 
  { 
    f*=i; 
  } 
  return f; 
} 
/* 
 1  2  6  24  120 
-------------------------------- 
Process exited after 0.02671 seconds with return value 5 
계속하려면 아무 키나 누르십시오 . . . 
*/

 

반응형

'2019~2020 > 자료구조' 카테고리의 다른 글

Queue  (0) 2019.05.13
스택 함수  (0) 2019.04.09
square 함수  (0) 2019.04.08
가장 큰 키, 가장 작은 키, 평균 구하기  (0) 2019.04.05
sin, cos 구하기  (0) 2019.04.05

+ Recent posts