Enter your Student ID: separating tens and ones, find ten factorial and factorial bit sum

Requirements: enter their student ID number: separating and ten bits, and the seeking ten factorial factorial sum bits; for example: 34 students 3 Calculation! +4! , Requires seeking a subroutine n! .

/*
* 学生学号阶乘代码 
*/
#include<stdio.h>

//函数声明 
int Muli(int,int);

void main()
{
	int a;
	int s,g;
	int m;
	printf("请输入学号:\n");
	scanf("%d",&a);
	s=a/10;
	g=a%10;
	printf("十位:%d\n个位:%d\n",s,g);
	//计算阶乘
	m=Muli(s,g);
	printf("%d的十位(%d)和个位(%d)的阶乘和为:%d\n",a,s,g,m);
} 
int Muli(int s,int g)
{
	int i,j;
	int b=1,c=1;
	for(i=s;i>0;i--)
	{
		b*=i;
	}
	for(j=g;j>0;j--)
	{
		c*=j;
	}
	return b+c;
}
Published 67 original articles · won praise 25 · views 20000 +

Guess you like

Origin blog.csdn.net/qq_41104871/article/details/104116501