-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path(1100)FunctionApplication.cpp
70 lines (70 loc) · 1.1 KB
/
(1100)FunctionApplication.cpp
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
68
69
70
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<math.h>
#include<malloc.h>
typedef float (*FP)(int num);
float f1(int num)
{
return (num*11+24);
}
float f2(int num)
{
return ((num>>3)+3);
}
float f3(int num)
{
return (num*num+10*num+31);
}
float f4(int num)
{
return (num/13+31);
}
float f5(int num)
{
return (num-sqrt(num));
}
float f6(int num)
{
return (sqrt(num));
}
float f7(int num)
{
return (num%206211);
}
float f8(int num)
{
return (num|10311999);
}
float f9(int num)
{
return (num&19991124);
}
float f10(int num)
{
return (num^11241031);
}
int main()
{
int operate;
FP fp;
scanf("%d",&operate);
int* opelist=(int *)malloc(3*operate*sizeof(int));
for(int i=0;i<operate;i++)
{
scanf("%d %d %d",&opelist[i*3],&opelist[i*3+1],&opelist[i*3+2]);
}
for(int k=0;k<operate;k++)
{
FP flist[10]={f1,f2,f3,f4,f5,f6,f7,f8,f9,f10};
fp=flist[(opelist[k*3])];
flist[(opelist[k*3])]=flist[(opelist[k*3+1])];
flist[(opelist[k*3+1])]=fp;
for(int j=0;j<10;j++)
{
opelist[k*3+2]=(int)(*flist[j])(opelist[k*3+2]);
}
printf("%d\n",opelist[k*3+2]);
}
return 0;
}