当前位置: 首页>>代码示例>>C++>>正文


C++ Matrice::bindMatriceElements方法代码示例

本文整理汇总了C++中Matrice::bindMatriceElements方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrice::bindMatriceElements方法的具体用法?C++ Matrice::bindMatriceElements怎么用?C++ Matrice::bindMatriceElements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Matrice的用法示例。


在下文中一共展示了Matrice::bindMatriceElements方法的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;
//.........这里部分代码省略.........
开发者ID:dcdogan,项目名称:Matrices,代码行数:101,代码来源:MatriceProgram.cpp


注:本文中的Matrice::bindMatriceElements方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。