-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFCTRL2.c
67 lines (49 loc) · 765 Bytes
/
FCTRL2.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include<stdio.h>
#include<stdlib.h>
short int fact[80];
short int length;
void Calc(short int num)
{
short int i,j,sum,temp;
for(i=1;i<80;i++)
fact[i]=0;
fact[0]=1;
length=1;
for(i=2;i<=num;i++)
{
j=temp=0;
while(j<length)
{
sum=temp+fact[j]*i;
fact[j]=sum%100;
j++;
temp=sum/100;
}
while(temp>0)
{
fact[j++]=temp%100;
temp=temp/100;
length++;
}
}
printf("%d",fact[length-1]);
for(i=length-2;i>=0;i--)
{
if(fact[i]>=10)
printf("%d",fact[i]);
else
printf("0%d",fact[i]);
}
printf("\n");
}
int main(void)
{
short int *t,tc,i;
scanf(" %d",&tc);
t=(short int *)malloc(sizeof(short int)*tc);
for(i=0;i<tc;i++)
scanf(" %d",&t[i]);
for(i=0;i<tc;i++)
Calc(t[i]);
return 0;
}