📄 074256_1.cpp
字号:
// 074256_1.cpp : Defines the entry point for the console application.
//074256_1.cpp
//07-11-22
//version 1.7
//To calculate the addition,substraction and multiplication of two matrix
#include"074256_1.h"
void main()
{
int row1=0;
int col1=0;
int row2=0;
int col2=0;
int **p_mat1;
int **p_mat2;
char choice;
//Title
printf("\n To calculate the addition,substraction and ");
printf("multiplication of two matrix\n");
printf(" ***********************************************************************\n\n");
for(;;)
{
//Matrix1
printf("\tMatrix1:\n");
read_cr(&row1,&col1); //read how many cols and rows
p_mat1=read_matrix(row1,col1); //read the Matrix from keyboard
//Matrix2
printf("\tMatrix2:\n");
read_cr(&row2,&col2); //read how many cols and rows
p_mat2=read_matrix(row2,col2); //read the Matrix
//print two Matrix for check
printf(" -------------------------------------------------------------------------\n");
printf("\tMatrix1:\n");
print_matrix(p_mat1,row1,col1);
printf("\tMatrix2:\n");
print_matrix(p_mat2,row2,col2);
//calculate
printf(" -------------------------------------------------------------------------\n");
printf(" The Answer is:\n\n");
add(p_mat1,row1,col1,p_mat2,row2,col2);
substract(p_mat1,row1,col1,p_mat2,row2,col2);
multiply(p_mat1,row1,col1,p_mat2,row2,col2);
//free memory
free_matrix(p_mat1,row1);
free_matrix(p_mat2,row2);
//return to the beginning
choice=getchar();
printf(" Do you want to continue? [Y]/[N]:\n\t");
for(;;)
{
scanf("%c",&choice);
if((choice>'a')&&(choice<'z'))
choice-='a'-'A';
clean;//
if((choice=='N')||(choice=='Y'))
break;
}
if(choice=='N') break;
else
clean();
printf("\n ************************************************************************\n");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -