#include"Matrix.h"
int Display_Main_Menu()
{
int ch;
system("cls");
printf("****************欢迎使用本稀疏矩阵运算系统******************\n");
printf(" 1.创建一个稀疏矩阵\n");
printf(" 2.销毁一个稀疏矩阵\n");
printf(" 3.显示所有稀疏矩阵的简要信息\n");
printf(" 4.显示指定稀疏矩阵的详细信息\n");
printf(" 5.复制一个已存在的矩阵\n");
printf(" 6.将两个矩阵相加\n");
printf(" 7.将两个矩阵相减\n");
printf(" 8.将两个矩阵相乘\n");
printf(" 9.求一个矩阵的转置\n");
printf(" 0.退出本系统\n");
printf("*************************************************************\n");
printf("*************************************************************\n");
printf("08计科1班 刘智君 3208006461 o(∩_∩)o...\n");
printf("--------------------------------------------------\n");
printf("数据之间请用【空格】隔开... \n");
printf("*************************************************************\n");
ch=getch();
return ch;
}
void Display_Menu_create(RTSMatrix *head)
{
int flag=1;
char cget;
while(flag)
{
system("cls");
if(CreateSMatrix(head))
{
printf("创建成功!继续?(Y/N)\n");
cget=getch();
if(cget=='n'||cget=='N') flag=0;
}
else
{
printf("创建失败!继续?(Y/N)\n");
cget=getch();
if(cget=='n'||cget=='N') flag=0;
}
}
}
void Display_Menu_destroy(RTSMatrix *head)
{
char name_buff[10];
int flag=1;
char cget;
while(flag)
{
system("cls");
PrintAllSMatrix(head);
printf("请输入要删除的矩阵:");
scanf("%s",name_buff);
if(DestroySMatrix(head,name_buff))
{
printf("删除成功!继续?(Y/N)\n");
cget=getch();
if(cget=='n'||cget=='N')
flag=0;
}
else
{
printf("删除失败!继续?(Y/N)\n");
cget=getch();
if(cget=='n'||cget=='N')
flag=0;
}
}
}
void Display_Menu_showall(RTSMatrix *head)
{
char cget;
int flag;
system("cls");
PrintAllSMatrix(head);
printf("按Q键返回主菜单!\n");
while(flag)
{
cget=getch();
if(cget=='Q'||cget=='q')
flag=0;
}
}
void Display_Menu_showdetal(RTSMatrix *head)
{
int flag=1;
char name_buff[10];
char cget;
RTSMatrix *M;
while(flag)
{
system("cls");
PrintAllSMatrix(head);
printf("请输入要详细显示的矩阵:");
scanf("%s",name_buff);
M=Find_Point(head,name_buff);
if(!M)
{
printf("没有找到相同名称的矩阵,重新输入?(Y/N)\n");
cget=getch();
if(cget=='n'||cget=='N') flag=0;
}
else
{
printf("已找到符合条件的矩阵!\n");
PrintSMatrix(M);
printf("继续显示其他矩阵?(Y/N)\n");
cget=getch();
if(cget=='n'||cget=='N') flag=0;
}
}
}
void Display_Menu_copy(RTSMatrix *head)
{
int flag;
char cget;
char name_buff[10];
RTSMatrix *M,*T;
while(flag)
{
system("cls");
PrintAllSMatrix(head);
printf("本子系统实现稀疏矩阵的复制!\n");
printf("请输入源矩阵M:");
scanf("%s",name_buff);
M=Find_Point(head,name_buff);
if(!M)
{
printf("没有找到相同名称的矩阵M,重新输入?(Y/N)\n");
cget=getch();
if(cget=='n'||cget=='N') flag=0;
}
else
{
printf("已找到符合条件的源矩阵M\n");
printf("请输入目的矩阵T:");
scanf("%s",name_buff);
T=Find_Point(head,name_buff);
if(T)
{
strcpy(T->name,name_buff);
}
else
{
T=(RTSMatrix *)malloc(sizeof(RTSMatrix));
T->next=head->next;
head->next=T;
strcpy(T->name,name_buff);
}
system("cls");
CopySMatrix(M,T);
printf("复制成功!\n");
PrintAllSMatrix(head);
printf("继续进行矩阵复制?(Y/N)\n");
cget=getch();
if(cget=='n'||cget=='N') flag=0;
}
}
}
void Display_Menu_add(RTSMatrix *head)
{
int flag=1,judgeadd=0;
char cget;
char name_buff[10];
RTSMatrix *M=NULL,*N=NULL,*Q=NULL;
while(flag)
{
system("cls");
PrintAllSMatrix(head);
printf("本子系统将执行Q=M+N!\n");
printf("请输入源矩阵M:");
scanf("%s",name_buff);
M=Find_Point(head,name_buff);
if(!M)
{
printf("没有找到相同名称的矩阵M,重新输入?(Y/N)\n");
cget=getch();
if(cget=='n'||cget=='N') flag=0;
}
else
{
printf("已找到符合条件的源矩阵M!\n");
while(flag&&N==NULL)
{
printf("请输入源矩阵N:");
scanf("%s",name_buff);
N=Find_Point(head,name_buff);
if(!N)
{
printf("没有找到相同名称的矩阵N,重新输入?(Y/N)\n");
cget=getch();
if(cget=='n'||cget=='N') flag=0;
}
else
printf("已找到符合条件的源矩阵N!\n");
}
if(flag)
{
printf("请输入目的矩阵Q:");
scanf("%s",name_buff);
Q=Find_Point(head,name_buff);
if(!Q)
{
Q=(RTSMatrix *)malloc(sizeof(RTSMatrix));
Q->next=head->next;
head->next=Q;
strcpy(Q->name,name_buff);
}
}
system("cls");
judgeadd=AddSMatrix(M,N,Q);
PrintAllSMatrix(head);;
if(judgeadd)
printf("矩阵相加成功!\n");
else
printf("矩阵相加失败!\n");
printf("继续进行矩阵相加?(Y/N)\n");
cget=getch();
if(cget=='n'||cget=='N') flag=0;
M=NULL;
N=NULL;
Q=NULL;
}
}
}
void Display_Menu_sub(RTSMatrix *head)
{
int flag=1,judgesub=0;
char cget;
char name_buff[10];
RTSMatrix *M=NULL,*N=NULL,*Q=NULL;
while(flag)
{
system("cls");
PrintAllSMatrix(head);
printf("本子系统将执行Q=M-N!\n");
printf("请输入源矩阵M:");
scanf("%s",name_buff);
M=Find_Point(head,name_buff);
if(!M)
{
printf("没有找到相同名称的矩阵M,重新输入?(Y/N)\n");
cget=getch();
if(cget=='n'||cget=='N') flag=0;
}
else
{
printf("已找到符合条件的源矩阵M!\n");
while(flag&&N==NULL)
{
printf("请输入源矩阵N:");
scanf("%s",name_buff);
N=Find_Point(head,name_buff);
if(!N)
{
printf("没有找到相同名称的矩阵N,重新输入?(Y/N)\n");
cget=getch();
if(cget=='n'||cget=='N') flag=0;
}
else
printf("已找到符合条件的源矩阵N!\n");
}
if(flag)
{
printf("请输入目的矩阵Q:");
scanf("%s",name_buff);
Q=Find_Point(head,name_buff);
if(!Q)
{
Q=(RTSMatrix *)malloc(sizeof(RTSMatrix));
Q->next=head->next;
head->next=Q;
strcpy(Q->name,name_buff);
}
}
system("cls");
judgesub=SubtMatrix(M,N,Q);
PrintAllSMatrix(head);;
if(judgesub)
printf("矩阵相减成功!\n");
else
printf("矩阵相减失败!\n");
printf("继续进行矩阵相减?(Y/N)\n");
cget=getch();
if(cget=='n'||cget=='N') flag=0;
M=NULL;
N=NULL;
Q=NULL;
}
}
}
void Display_Menu_mul(RTSMatrix *head)
{
int flag=1,judgemul=0;
char cget;
char name_buff[10];
RTSMatrix *M=NULL,*N=NULL,*Q=NULL;
while(flag)
{
system("cls");
PrintAllSMatrix(head);
printf("本子系统将执行Q=M*N!\n");
printf("请输入源矩阵M:");
scanf("%s",name_buff);
M=Find_Point(head,name_buff);
if(!M)
{
printf("没有找到相同名称的矩阵M,重新输入?(Y/N)\n");
cget=getch();
if(cget=='n'||cget=='N') flag=0;
}
else
{
printf("已找到符合条件的源矩阵M!\n");
while(flag&&N==NULL)
{
printf("请输入源矩阵N:");
scanf("%s",name_buff);
N=Find_Point(head,name_buff);
if(!N)
{
printf("没有找到相同名称的矩阵N,重新输入?(Y/N)\n");
cget=getch();
if(cget=='n'||cget=='N') flag=0;
}
else
printf("已找到符合条件的源矩阵N!\n");
}
if(flag)
{
printf("请输入目的矩阵Q:");
scanf("%s",name_buff);
Q=Find_Point(head,name_buff);
if(!Q)
{
Q=(RTSMatrix *)malloc(sizeof(RTSMatrix));
Q->next=head->next;
head->next=Q;
strcpy(Q->name,name_buff);
}
}
system("cls");
judgemul=MultSMatrix(M,N,Q);
PrintAllSMatrix(head);;
if(judgemul)
printf("矩阵相乘成功!\n");
刘良运
- 粉丝: 77
- 资源: 1万+
最新资源
- 废弃 arc90 可读性书签的 Python 端口.zip
- 毕业设计背单词微信小程序.zip
- Zulip API 的 Python 库 .zip
- Zipline,一个 Pythonic 算法交易库.zip
- YARA 的 Python 接口.zip
- 自动化unittest框架示例报告
- JS+CSS3文章内容背景黑白切换特效代码.zip
- 11.2.0.4.221018-DB PSU p34474433-112040-MSWIN-x86-64.zip
- Wkhtmltopdf python 包装器将 html 转换为 pdf.zip
- Windows 事件日志文件 (.evtx) 的纯 Python 解析器.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0