2021-10-03 02:28:37 +00:00
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
2021-10-08 09:17:16 +00:00
|
|
|
|
#include "vec.cpp"
|
2021-10-03 02:28:37 +00:00
|
|
|
|
int main()
|
|
|
|
|
{
|
2021-10-08 09:17:16 +00:00
|
|
|
|
int flag = 0;
|
|
|
|
|
int temp[5];
|
|
|
|
|
|
|
|
|
|
srand(time(NULL));
|
|
|
|
|
int len;
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
scanf("%d", &len);
|
|
|
|
|
Vec v(len);
|
|
|
|
|
v.printall();
|
2021-10-03 02:28:37 +00:00
|
|
|
|
system("pause");
|
2021-10-15 07:20:32 +00:00
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<3A><>Ϊ%d\n",v.getused());
|
|
|
|
|
// v.bubbleSort();
|
|
|
|
|
v.mergeSort(0,v.getused());
|
2021-10-08 09:17:16 +00:00
|
|
|
|
v.printall();
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
2021-10-08 09:26:01 +00:00
|
|
|
|
printf("ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:1.<2E><><EFBFBD><EFBFBD> 2.ɾ<><C9BE> 3.ͳ<><CDB3> 4.<2E>˳<EFBFBD>\n");
|
2021-10-08 09:17:16 +00:00
|
|
|
|
scanf("%d", &flag);
|
|
|
|
|
|
|
|
|
|
switch (flag)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ\n");
|
|
|
|
|
scanf("%d", &temp[0]);
|
2021-10-15 08:45:28 +00:00
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ%d<><64>\n",v.search(temp[0]) + 1);
|
2021-10-15 07:20:32 +00:00
|
|
|
|
(v.insert(v.search(temp[0]) + 1, temp[0]) != -1) ? (printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n")) : (printf("<EFBFBD><EFBFBD>Ԫ<EFBFBD>ػ<EFBFBD><EFBFBD><EFBFBD>Χ\n"));
|
2021-10-08 09:17:16 +00:00
|
|
|
|
v.printall();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD>\n");
|
|
|
|
|
scanf("%d", &temp[0]);
|
|
|
|
|
(v.remove_sorted(temp[0]) != -1) ? (printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n")) : (printf("<EFBFBD><EFBFBD>Ԫ<EFBFBD>ػ<EFBFBD><EFBFBD><EFBFBD>Χ\n"));
|
|
|
|
|
v.printall();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD>Ƶ<EFBFBD><EFBFBD><EFBFBD>ֵ\n");
|
|
|
|
|
scanf("%d", &temp[0]);
|
|
|
|
|
temp[1] = v.count(temp[0]);
|
|
|
|
|
|
|
|
|
|
(temp[1] != -1) ? (printf("һ<EFBFBD><EFBFBD>%d<><64>\n", temp[1])) : (printf("<EFBFBD><EFBFBD>Ԫ<EFBFBD>ػ<EFBFBD><EFBFBD><EFBFBD>Χ\n"));
|
|
|
|
|
break;
|
|
|
|
|
|
2021-10-08 09:26:01 +00:00
|
|
|
|
case 4:
|
|
|
|
|
return 0;
|
2021-10-15 07:20:32 +00:00
|
|
|
|
|
2021-10-08 09:17:16 +00:00
|
|
|
|
default:
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD>ز˵<EFBFBD>\n");
|
|
|
|
|
}
|
|
|
|
|
flag = 0;
|
|
|
|
|
}
|
2021-10-03 02:28:37 +00:00
|
|
|
|
return 0;
|
2021-10-15 07:20:32 +00:00
|
|
|
|
}
|