예제 #1
0
int main (void){
    
    long number, factorial;
    
    number = getNumber();
    factorial = getfactorial(number);
    
    printf("The factorial of %ld is %ld\n", number, factorial);
    
    
}
예제 #2
0
int main(int argc,char *argv[])
{
	if (argc==1)
		printf("no arg is define,default calculate the factorial summation from 1 to 10 is %d.\n",getfactorial(1,10));
	else if (argc==2)
	{
		int iarg=atoi(argv[1]);
		if (iarg>10)
			printf("The first arg is greater than 10, so calculate the factorial summation form 10 to %d is %d.\n",iarg,getfactorial(10,iarg));
		else
			printf("The first arg is less than 10, so calculate the factorial summation form %d to 10 is %d.\n",iarg,getfactorial(iarg,10));
	}
	else
	{
		int iargs[2];
		iargs[0]=atoi(argv[1]);
		iargs[1]=atoi(argv[2]);
		printf("The first arg is less than 10, so calculate the factorial summation form %d to %d is %d.\n",iargs[0],iargs[1],getfactorial(iargs[0],iargs[1]));
	}	
	return 0;
}