C++程序问题!!!急~~~

来源:百度知道 编辑:UC知道 时间:2024/05/24 12:39:20
1.稀疏矩阵运算器,用十字链表表示系数矩阵,能运算加法,减法,乘法.

2.校园导游咨询程序
包涵景点:教学楼A-G,餐厅,宿舍楼,综合楼,共10个
为客人提供任意景点的相关信息
为客人选择2个景点中最短路径

#include <iostream>
#include <iomanip>
using namespace std;
const int MAXSIZE=100; // 定义非零元素的对多个数
const int MAXROW=10; // 定义数组的行数的最大值
typedef struct { // 定义三元组的元素
int i,j;
int e;
}Triple;
typedef struct { // 定义普通三元组对象
Triple data[MAXSIZE+1];
int mu,nu,tu;
}TSMatrix;
typedef struct { // 定义带链接信息的三元组对象
Triple data[MAXSIZE+2];
int rpos[MAXROW+1];
int mu,nu,tu;
}RLSMatrix;
template <class P>
bool InPutTSMatrix(P & T,int y){ //输入矩阵,按三元组格式输入
cout<<"输入矩阵的行,列和非零元素个数:"<<endl;
cin>>T.mu>>T.nu>>T.tu;
cout<<"请输出非零元素的位置和值:"<<endl;
int k=1;
for(;k<=T.tu;k++)
cin>>T.data[k].i>>T.data[k].j>>T.data[k].e;

return true;
}
template <class P>
bool OutPut