-
Notifications
You must be signed in to change notification settings - Fork 0
/
server_functions.c
executable file
·78 lines (55 loc) · 1.19 KB
/
server_functions.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
68
69
70
71
72
73
74
75
76
77
78
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
/* return: OUT; a, b: IN */
int f0(int a, int b) {
return a + b;
}
/* returns: OUT; a, b, c, d: IN */
long f1(char a, short b, int c, long d) {
return a + b * c - d;
}
/* return string is the concatenation of the integer
part of the float and the interger part of the double
return: OUT string; a, b: IN */
char* f2(float a, double b) {
float ai;
double bi;
char *str1;
char *str2;
a = modff(a, &ai);
b = modf(b, &bi);
str1 = (char *)malloc(100);
sprintf(str1, "%lld%lld", (long long)ai, (long long)bi);
return str1;
}
/*
* bubble sort
* the first element in the array indicates the size of the array
* a: INOUT array
*/
void f3(long a[]) {
int len = a[0];
int i, j, k;
for (i = 0; i < len; i++) {
for (j = len - 1; j > i; j--) {
if (a[j] > a[j - 1]) {
k = a[j];
a[j] = a[j - 1];
a[j - 1] = k;
}
}
}
}
/*
* print file named by a
* a: IN array
*/
void f4(char a[]) {
/* print file a to a printer */
}
int g5(int a, int b) {
return a * b;
}