-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest.c
51 lines (49 loc) · 820 Bytes
/
test.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
#include <stdio.h>
#include <linux/kernel.h>
#include <sys/syscall.h>
#include <unistd.h>
#include <time.h>
#include <sys/time.h>
#include <string.h>
#include <errno.h>
unsigned long long nCr(unsigned long long n, unsigned long long r)
{
if(n>=r)
{
if(r==0 || r==n)
{
return 1;
}
else
{
return nCr(n-1,r-1) + nCr(n-1,r);
}
}
else
{
return 0;
}
}
int main()
{
long int pid=fork();
if(pid!=0)
{
long ret = syscall(323,pid,200);
printf("%s\n",strerror(ret));
}
if(pid==0)
{
unsigned long long ans = nCr(30,15);
printf("Finished calculating 30C15\n");
printf("Process with PID %ld finished\n",getpid());
}
else
{
unsigned long long ans = nCr(24,12);
printf("Finished calculating 24C12\n");
printf("Process with PID %ld finished\n",getpid());
wait(pid);
}
return 0;
}