1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.4 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include "Benchmark.h"
#include "SeqList.h"
typedef int DataType;
#include <functional>
using namespace std;
int main()
{
benchmark_hw2_1(5, 600, 5, 200);
benchmark_hw2_3(5, 600, 5, 200);
//测试一测试顺序表类SeqList类
SeqList<DataType> myList;
int i;
DataType x;
int n = 10;
for (i = 1; i <= n; i++) //顺序插入10个元素
myList.Insert(i - 1, i); // 在尾部处插入i+1
myList.output();
myList.Remove(4, x); //删除myList中数据元素4
myList.output();
//测试二:测试有序顺序表
SeqList<DataType> myLista(10), myListb(15), myListc(10);
int test1[10] = {6, 8, 1, 8, 1, 7, 1, 1, 1, 1};
int test2[15] = {7, 8, 2, 7, 6, 8, 2, 6, 9, 10, 1, 3, 4, 11, 35};
myLista.OrderMake(test1, 10);
myLista.output(); //正确输出是1 1 1 1 1 1 6 7 8 8
myListb.OrderMake(test2, 15);
myListb.output(); //正确输出是1 2 2 3 4 6 6 7 7 8 8 9 10 11 35
//插入你完成第二个任务的代码把有序顺序表myLista和myListb合并到有序顺序表myListc中并输出myListc。
myListc.Merge(myLista, myListb);
myListc.output(); //输出应该为1 1 1 1 1 1 1 2 2 3 4 6 6 6 7 7 7 8 8 8 8 9 10 11 35
//测试三有序顺序表myListc中删除多余的8的结果。
DataType y = 8;
myListc.MoreRemove(y);
myListc.output(); //输出应该为1 1 1 1 1 1 1 2 2 3 4 6 6 6 7 7 7 9 10 11 35
cout << "Done.\n"
<< endl;
system("pause");
return 0;
}