-
Notifications
You must be signed in to change notification settings - Fork 5
/
hw1.c
executable file
·122 lines (83 loc) · 1.61 KB
/
hw1.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
* Author :
* Description:
*
*
*/
#include <stdio.h>
/**
* @brief return the sysmetric index of a given index if an array
* @details
* for [1,2,3], the 0th sysmetric index is 2th
* for [1,2,3,4], the 0th sysmetric index is 3th
*
* @param arr integer array
* @param len length
* @param ith given index
*/
int sysmetric_index(int len, int ith)
{
/* code */
}
/**
* @brief reverse the order of items in an integer array
* @details for example, [1,2,3] after reversing is [3,2,1]
*
* @param arr integer array
* @param len array length
*/
void reverse_in_place(int arr[], int len)
{
/* code */
}
/**
* @brief return the first index of the largest item in the array
* @details [long description]
*
* @param arr [description]
* @param len [description]
*
* @return [description]
*/
int argmax(int arr[], int len)
{
/* code */
}
void accumulate_sum(int arr[], int len)
{
/* code */
}
void decimal2base_q(int num, char num_q[], int q)
{
/* code */
}
int base_q2decimal(char num_q[], int q)
{
/* code */
}
void shuffleString(char s[], int arr[], int len)
{
/* code */
}
void print_1d_ints(int arr[], int len)
{
for (int i = 0; i < len; ++i)
{
printf("%d\t", arr[i]);
}
printf("\n");
}
void reverse_in_place_test()
{
int arr[] = {1,2,3,4};
printf("\nreverse_in_place_test:\n");
print_1d_ints(arr, 4);
reverse_in_place(arr, 4);
print_1d_ints(arr, 4);
}
int main(int argc, char const *argv[])
{
printf("hello, world!\n");
reverse_in_place_test();
return 0;
}