This repository has been archived on 2024-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
justhomework/ex3/ex3.cpp

57 lines
1.3 KiB
C++
Raw Normal View History

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-08 09:17:16 +00:00
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
v.sort();
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]);
(v.insert(v.search(temp[0]), 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 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-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;
}