
(新编)数据结构程序.doc
23页实验 1:tast-sq-list#include "utility.h" // 实用程序软件包#include "sq_list.h" // 顺序表类int main(void){char c = '0';SqList la,lb;double e;int position;while (c != '7'){cout > c;switch (c) {case '1':cout > e;while (e != 0){la.Insert(la.Length() + 1, e);cin >> e;}break;case '2':lb = la;lb.Traverse(Write);break;case '3':cout > position;if (la.GetElem(position, e) == NOT_PRESENT) cout > position;cout > e;if (la.SetElem(position, e) == RANGE_ERROR)cout > position;if (la.Delete(position, e) == RANGE_ERROR) cout > position;cout > e;if (la.Insert(position, e) == RANGE_ERROR) cout la,lb;double e;int position;while (c != '7'){cout > c;switch (c) {case '1':cout > e;while (e != 0){la.Insert(la.Length() + 1, e);cin >> e;}break;case '2':lb = la;lb.Traverse(Write);break;case '3':cout > position;if (la.GetElem(position, e) == NOT_PRESENT) cout > position;cout > e;if (la.SetElem(position, e) == RANGE_ERROR)cout > position;if (la.Delete(position, e) == RANGE_ERROR) cout > position;cout > e;if (la.Insert(position, e) == RANGE_ERROR) cout sa,sb;double x;while (c != '6'){cout > c;switch (c) {case '1':cout > x;if (x != 0)sa.Push(x);}break;case '2':sb = sa;cout );break;case '3':cout > x;sa.Push(x);break;case '4':sa.Pop(x);cout qa,qb;double x;while (c != '6'){cout > c;switch (c) {case '1':cout > x;if (x != 0)qa.InQueue(x);}break;case '2':qb = qa;cout );break;case '3':cout > x;qa.InQueue(x);break;case '4':qa.OutQueue(x);cout a(n, n); // 定义一个 n 行 n 列稀疏矩阵int b[n][n] = {1, 0, 3, 0, 0, 4, 0, 6, 0, 0, 0, 0, 8, 9, 0, 0, 0, 0, 1, 12,1, 0, 0, 3, 1};int i, j, v; // 工作变量// 设置稀疏矩阵 a 的元素值for (i = 1; i c(a); // 复制构造函数c = a; // 赋值运算符重载// 显示稀疏矩阵 cfor (i = 1; i a(n, n); // 定义一个 n 行 n 列稀疏矩阵int b[n][n] = {1, 0, 3, 0, 0, 4, 0, 6, 0, 0, 0, 0, 8, 9, 0, 0, 0, 0, 1, 12,1, 0, 0, 3, 1};int i, j, v; // 工作变量// 设置稀疏矩阵 a 的元素值for (i = 1; i c(a); // 复制构造函数c = a; // 赋值运算符重载// 显示稀疏矩阵 cfor (i = 1; i preInBt;preInBt = CreateBinaryTree(pre, in, n);// 构造二叉树cout (preInBt);cout thrBt(preInBt);DisplayBTWithTreeShape(thrBt);system("PAUSE"); // 调用库函数 system()cout );cout bt(thrBt);cout (bt);system("PAUSE"); // 调用库函数 system()cout );cout(bt);system("PAUSE"); // 调用库函数 system()cout );cout preInBt;preInBt = CreateBinaryTree(pre, in, n);// 构造二叉树cout (preInBt);cout thrBt(preInBt);DisplayBTWithTreeShape(thrBt);system("PAUSE"); // 调用库函数 system()cout );cout bt(thrBt);cout (bt);system("PAUSE"); // 调用库函数 system()cout );cout(bt);system("PAUSE"); // 调用库函数 system()cout );cout preInBt;preInBt = CreateBinaryTree(pre, in, n);// 构造二叉树cout (preInBt);cout thrBt(preInBt);DisplayBTWithTreeShape(thrBt);system("PAUSE"); // 调用库函数 system()cout );cout bt(thrBt);cout (bt);system("PAUSE"); // 调用库函数 system()cout );cout(bt);system("PAUSE"); // 调用库函数 system()cout );cout g(vexs, n);for (int u = 0; u (g, Write);// 用于确定函数模板参数cout g(vexs, n);for (int u = 0; u (g, Write); // 用于确定函数模板参数cout net(vexs, n);for (int u = 0; u net(vexs, n);for (int u = 0; u g(vexs, n);for (int u = 0; u net(vexs, n);for (int u = 0; u bt;int elem[] = {6, 3, 9, 5, 8};int n = 5;for (int i = 0; i btNew(bt); // 复制构造新树cout );cout);cout);cout);cout bt;int elem[] = {6, 3, 9, 5, 8};int n = 5;for (int i = 0; i btNew(bt); // 复制构造新树cout );cout);cout);cout);cout<
