本文整理汇总了C++中Matrice::printMatrice方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrice::printMatrice方法的具体用法?C++ Matrice::printMatrice怎么用?C++ Matrice::printMatrice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrice
的用法示例。
在下文中一共展示了Matrice::printMatrice方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
cout<<"Welcome to matrix operation program"<<endl;
cout<<"This program is developed for matrix operation, first matrix is read by a file"<<endl;
cout<<"You must give dimensions of second matrice and program will generate a matrix with random values, then you can go to matrix operations."<<endl;
cout<<endl;
// File handling part
Matrice FileMatrice ;
FileMatrice.readLinesFromFile() ;
cout<< "Here is a matrix with size: "<<FileMatrice.rowSize<<"x"<<FileMatrice.columnSize<<endl;
FileMatrice.printMatrice();
// create a random matrice struct called RandomMatrice
Matrice RandomMatrice ;
// we should get the dimension from the user in this scheme: row x column
// so I am creating a string with 3 bytes to get it
char getMatriceSize[3] ;
cout << "Please enter the dimensions of the matrice (e.g. 2x3):" ;
cin >> getMatriceSize ;
cout << "Here is a matrice with size of "<< getMatriceSize << "\n" ;
// we can add exception here in case of user enters invalid size
// In order to get the size, I subtsracted ascii value '0' from the char value
RandomMatrice.rowSize = getMatriceSize[0]-'0';
//cout << "Row size "<< rowSize << "\n" ;
// Same operation for column size of the matrice
RandomMatrice.columnSize = getMatriceSize[2]-'0';
//cout << "Column size "<< columnSize << "\n" ;
// allocate memory for given dimension in random matrice
RandomMatrice.allocateMemoryForMatriceElements() ;
// get random values for the matrice
//for random values
srand(time(NULL));
RandomMatrice.getRandomValuesForMatriceElements() ;
// print the matrice with new elements
RandomMatrice.printMatrice() ;
RandomMatrice.bindMatriceElements() ;
// Menu
bool menuChoice = true; // boolean value for menu choice (continue ? (Y or N))
char operationChoice ; // char value for menu operations
char askIfTheUserWantsToContinueOperations ;
while (menuChoice){
cout << "\t\t\tMatrice Operation Menu\n" ;
cout << "Select one of the matrice operations: \n" ;
cout<< "1. Multiply the matrices and print the result to the screen.(M)\n"<<
"2. Find transpose of the matrices (both) and print them to the screen.(T)\n"<<
"3. Check if the matrices are symmetric.(S)\n"<<
"4. Check if the matrices are zero matrix.(Z)\n"<<
"5. Calculate the determinant of the matrices.(D)\n";
cin>> operationChoice ;
switch (operationChoice) {
case 'M' | 'm':
matrixMultiplication(FileMatrice, RandomMatrice);
break;
case 'T' | 't':
//statements
transpozeOperation(FileMatrice, RandomMatrice);
break;
case 'S' | 's':
//statements
checkIfSymmetric(FileMatrice, RandomMatrice);
break;
case 'Z' | 'z':
//statements
checkIfZeroMatrix(FileMatrice, RandomMatrice);
break;
case 'D' | 'd':
//statements
determinantOperation(FileMatrice, RandomMatrice);
break;
default:
break;
//.........这里部分代码省略.........