-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.cpp
310 lines (293 loc) · 7.19 KB
/
test.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
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
//
// Created by Giperx on 2023/7/22.
//
#include <iostream>
#include <vector>
#include "structDef/List/SqList.h"
#include "structDef/List/LinkList.h"
#include "week1/day03/day03.h"
#include "week2/day04/day04.h"
#include "week2/day05//day05.h"
#include "week2/day06/day06.h"
#include "week2/day07/day07.h"
#include "week2/day08/day08.h"
#include "week2/day09/day09.h"
#include "week3/day10/day10.h"
#include "week3/day11/day11.h"
#include "week3/day12/day12.h"
#include "week3/day13/day13.h"
#include "week3/day14/day14.h"
#include "week3/day15/day15.h"
#include "week4/day16/day16.h"
#include "week4/day17/day17.h"
#include "week4/day18/day18.h"
#include "week4/day19/day19.h"
#include "week4/day20/day20.h"
#include "week4/day21/day21.h"
#include "week5/day22/day22.h"
#include "week5/day23/day23.h"
#include "week5/day24/day24.h"
#include "week5/day25/day25.h"
#include "week5/day27/day27.h"
#include "week6/day28/day28.h"
#include "week6/day29/day29.h"
#include "week6/day30/day30.h"
using namespace std;
// day30 按照递增输出单链表结点数据元素
int main(){
LinkList L;
initLinkList(L);
int n, tmp;
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> tmp;
appendLinkListRear(L, tmp);
}
printSortLinkList(L, n);
return 0;
}
//// day23 day24 day25 day27 day28 day29
//int main(){
// LinkList L;
// initLinkList(L);
// int n, tmp;
// cin >> n;
// for (int i = 0; i < n; ++i) {
// cin >> tmp;
// appendLinkListRear(L, tmp);
//// appendLinkListFront(L, tmp);
// }
//// reverseLinkList(L);
// printLinkList(L);
// cout << "after:" << endl;
//// reversePrintLinkList(L->next);
// // find倒数第k个结点
//// int k;
//// cin >> k;
//// cout << findLastK(L, k) << endl;
// // 两个链表AB奇偶存放
//// LinkList B;
//// B = divideTwoLinkList(L);
//// printLinkList(L);
//// printLinkList(B);
// // 删除最小值结点
// delMinOfLinkList(L);
// printLinkList(L);
// return 0;
//}
//int main(){
// SqList list;
// initSqList(list);
// printSqList(list);
//
// cout << "after :" << endl;
// printSqList(list);
// return 0;
//}
//// day 22
//int main(){
// int A[3] = {-1, 0, 9},
// B[4] = {-25, -10, 10, 11},
// C[5] = {2, 9, 17, 30, 41};
// cout << findMinDistofTrip(A, 3, B, 4, C, 5) << endl;
// return 0;
//}
//// day19 day20 day21
//int main(){
// //day19
//// int arrA[5] = {2, 4, 6, 8, 20}, arrB[5] = {11, 13, 15, 17, 19};
//// cout << SerachMiddleInTwo(arrA, arrB, 5);
// // day20
//// int arr[8] = {0, 5, 5, 3, 5, 7, 5, 5};
//// int arr[8] = {0, 5, 5, 3, 5, 1, 5, 7};
//// cout << findMajorityElement(arr, 8) << endl;
// // day21
//// int arr[4] = {1, 2, 3, 4};
// int arr[4] = {1, 2, 5, 9};
// cout << findMinNotIn(arr, 4) << endl;
// return 0;
//}
//// day15 day16 day17 day18
//int main(){
// int n;
// cin >> n;
// int arr[n];
// for(auto &x:arr){
// cin >> x;
// }
// for(auto x:arr) cout << x << ' ';
// cout << "enter p:";
// int p;
// cin >> p;
// cout << endl;
//// quickSort(arr, 0, n - 1);
//// bubbleSort(arr, n);
//// selectSort(arr, n);
//// insertSort(arr, n);
// leftRotate(arr, n, p);
// cout << "after :" << endl;
// for(auto x:arr) cout << x << ' ';
// cout << endl;
// return 0;
//}
//// day14
//int main(){
// vector<int> arr;
// int n, tmp, target;
// cin >> n;
// for (int i = 0; i < n; ++i) {
// cin >> tmp;
// arr.emplace_back(tmp);
// }
// cin >> target;
// cout << binarySearch(arr,target) << endl;
// return 0;
//}
//// day13
//int main(){
// vector<vector<int>> arr;
// int row, col;
// cin >> row >> col;
// for (int i = 0; i < row; ++i) {
// vector<int> tmp;
// for (int j = 0; j < col; ++j) {
// int m;
// cin >> m;
// tmp.emplace_back(m);
// }
// arr.emplace_back(tmp);
// }
//
// for(auto x:arr){
// for(auto y:x){
// cout << y << ' ';
// }
// cout << endl;
// }
// int target;
// cin >> target;
// cout << searchInSortedArray(arr, target) << endl;
// return 0;
//}
//// day12
//int main(){
// SqList list;
// initSqList(list);
// printSqList(list);
// cout << "enter two list lengths:" << endl;
// int l1, l2;
// cin >> l1 >> l2;
// cout << "after :" << endl;
// superReverse(list, l1, l2);
// printSqList(list);
// return 0;
//}
//// day11
//int main(){
// SqList list1;
// cout << "init sorted list1" << endl;
// initSqList(list1);
// printSqList(list1);
// SqList list2;
// cout << "init sorted list2" << endl;
// initSqList(list2);
// printSqList(list2);
// cout << "after :" << endl;
// SqList *tmp;
// tmp = CombineSqList(list1, list2);
// printSqList(*tmp);
// return 0;
//}
//// day10
//int main(){
// SqList list;
// cout << "init sorted list" << endl;
// initSqList(list);
// printSqList(list);
// cout << "enter value a and b to delete list(sorted):";
// int a, b;
// cin >> a >> b;
// deleteSortedValueRange(list, a, b);
// cout << "after :" << endl;
// printSqList(list);
// return 0;
//}
//// day09
//int main(){
// SqList list;
// initSqList(list);
// printSqList(list);
// deleteDuplicate(list);
// cout << "after :" << endl;
// printSqList(list);
// return 0;
//}
//// day08
//int main(){
// SqList list;
// initSqList(list);
// printSqList(list);
// int a, b;
// cout << "enter value range a and b to delete:";
// cin >> a >> b;
// deleteValueRange(list, a, b);
// cout << "after :" << endl;
// printSqList(list);
// return 0;
//}
//// day07
//int main(){
// SqList list;
// initSqList(list);
// printSqList(list);
// partition(list);
// cout << "after partition:" << endl;
// printSqList(list);
// return 0;
//}
//// day06
//int main(){
// SqList list;
// cin >> list.length;
// for(int i = 0; i < list.length; i ++) cin >> list.data[i];
// for(int i = 0; i < list.length; i ++) cout << list.data[i] << ' ';
// cout << endl << "to delete range from i to j:";
// int i, j;
// cin >> i >> j;
// deleteRange(list, i, j);
// for(int i = 0; i < list.length; i ++) cout << list.data[i] << ' ';
// return 0;
//}
//// day05
//int main(){
// SqList list;
// int x;
// cin >> list.length;
// for(int i = 0; i < list.length; i ++) cin >> list.data[i];
// for(int i = 0; i < list.length; i ++) cout << list.data[i] << ' ';
// cout << endl << "to delete value x:";
// cin >> x;
// deleteX(list, x);
// for(int i = 0; i < list.length; i ++) cout << list.data[i] << ' ';
// return 0;
//}
//// day04
//int main(){
// SqList list;
// cin >> list.length;
// for(int i = 0; i < list.length; i ++) cin >> list.data[i];
// for(int i = 0; i < list.length; i ++) cout << list.data[i] << ' ';
// cout << endl;
// reverseSqList(list);
// for(int i = 0; i < list.length; i ++) cout << list.data[i] << ' ';
// return 0;
//}
//// day03
//int main(){
// int n = 5;
// int a[5] = {5, 2, 1, 4, 8};
// cout << DeleteMinRet(a, n) << endl;
// for(auto x:a) cout << x << ' ';
// cout << endl << n;
// return 0;
//}