1. Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Need C++ project ideas!

Discussion in 'Programming & Webmastering' started by Maelstrom, Jan 27, 2011.

  1. joomlads07 New Member

    Joined:
    Feb 17, 2010
    Messages:
    2 (0.00/day)
    Thanks Received:
    1
    Location:
    3 Locust Street, Suite A Assonet, MA 02702
    Linux system tools. I do a lot of these because you don't have to waste hours of your life writing a pretty user interface

    The sorts of things I am doing lately are as follows...

    * RPN math solver (command line math or read from file).
    * Assembly Language interpreter (a proprietary conceptual demo).
    * C/MySQL interface generator (builds corresponding DB tables and C structs based on lists).
     
    Maelstrom says thanks.
  2. Maelstrom

    Joined:
    Sep 10, 2008
    Messages:
    532 (0.17/day)
    Thanks Received:
    159
    Location:
    VA/PA
    Oh crap, sorry, didn't realize people we're still responding to this thread, lol.

    Project wise? Nothing. This semester has become much busier than I expected it to be (a ton of reading for multiple classes). So basically what I have been doing is reading the c++ tutorial on cplusplus.org (.com?) and then using all that I learn on making my c++ assignments waaaaaay overcomplicated :roll:. It's lots of fun, plus I am learning a good deal too. Once I have some time I'll sit down and work on some of the projects y'all suggested (spring break/summer). Damn college and its work, shouldn't it know by now that college is for fun and goofing off :p
     
    Last edited: Feb 9, 2011
  3. Kreij

    Kreij Senior Monkey Moderator Staff Member

    Joined:
    Feb 6, 2007
    Messages:
    13,817 (3.67/day)
    Thanks Received:
    5,628
    Location:
    Cheeseland (Wisconsin, USA)
    Good for you. Stick with it and all the hard work will pay off. :toast:
     
    Maelstrom says thanks.
    10 Year Member at TPU
  4. xbonez New Member

    Joined:
    Nov 29, 2010
    Messages:
    1,182 (0.50/day)
    Thanks Received:
    315
    Location:
    Philly, PA (US)
    While its extremely important to learn by reading concepts and stuff, one thing I have realized from personal experience is things don't persist in mind for long unless you actually utilize them. What I do, when learning a language is learn a concept (say dictionaries), then write a tiny program right away to use them. Keep building on this, so if the next concept u learn is serializing/deserializing XMLs, write a program that, say, deserializes an xml, adds the data to a dictionary.
     
    Maelstrom says thanks.
  5. MadClown

    MadClown

    Joined:
    Jun 24, 2008
    Messages:
    1,365 (0.42/day)
    Thanks Received:
    109
    Location:
    Alden, NY
    make a video game, about dolphins with flamethrowers
     
    Maelstrom says thanks.
  6. Kreij

    Kreij Senior Monkey Moderator Staff Member

    Joined:
    Feb 6, 2007
    Messages:
    13,817 (3.67/day)
    Thanks Received:
    5,628
    Location:
    Cheeseland (Wisconsin, USA)
    Fixed. lol
     
    10 Year Member at TPU
  7. Brandenburg

    Brandenburg New Member

    Joined:
    Feb 13, 2011
    Messages:
    171 (0.07/day)
    Thanks Received:
    31
    Location:
    Waco,Texas
    I go through the same thing as the OP on what projects to undertake. But for me.. I do a sort of cost/time/usability analysis..As my time it worth something.. even to me.Kind of abstract concept and rarely is anything put to paper... Took me 6+ months to decide on my last project.. A board game to PC convert thats in VB and is like 5000 lines now.. not a small undertaking:banghead: Originally.. It was just to learn new ideas AND was never really meant to finish it.. 55% or so percent later.. LOL.. I think I will eventually finish it

    When I was in school for Electronics, I wrote two programs.. One was for instantaneous voltage/current and the other was a very professional looking program for my physics teacher called Vector Summation..:nutkick:Granted.. all are written in Visual Basic 2007 but I could of done it in C++,Java, or C#..BUT VB is so much faster and VB is my love. I'm at the point now, it's what I call.. "Perpetual Learning"..

    I do the same thing but I start out with a larger project that has alot of concepts in it

    My next idea might be to scan my movies/music folder and catalog all items and export it to an excel file

    @ the OP
    Let us know what project idea you have decided on..To be honest.. I cant think of any projects for you.. Last project in C++ I did was to write the game farkle using GDI and to start on a black jack game done in console
     
    Maelstrom says thanks.
  8. Maelstrom

    Joined:
    Sep 10, 2008
    Messages:
    532 (0.17/day)
    Thanks Received:
    159
    Location:
    VA/PA
    Spring break is getting closer (hellz ya!), just gotta get through 4 o'clock quizzes (think midterm, but instead of 2 exams per semester, its 3). Once that's done, its selling pc parts/c++ project time! Was thinking about going through this list I found of project ideas http://www.cplusplus.com/forum/beginner/3473/. # 25 on the list would be useful for my differential equations and linear algrebra class :toast: (though my calculator can already do them :laugh:)

    Edit: Holy crap, got the best idea ever for my math class. Expand on matrix multiplication/addition and make it so the program can do E.R.O http://en.wikipedia.org/wiki/Elementary_row_operations. Oh ya, that's my next project, as that will be very helpful for my class!!
     
  9. Brandenburg

    Brandenburg New Member

    Joined:
    Feb 13, 2011
    Messages:
    171 (0.07/day)
    Thanks Received:
    31
    Location:
    Waco,Texas
    After reading what I had wrote again

    VB is faster to develop BUT not in actual speed of execution ... Most new what I meant I feel but.......
     
  10. Kreij

    Kreij Senior Monkey Moderator Staff Member

    Joined:
    Feb 6, 2007
    Messages:
    13,817 (3.67/day)
    Thanks Received:
    5,628
    Location:
    Cheeseland (Wisconsin, USA)
    They asked me to write a database based ERP program at work. Last time I checked it was at about 50,000 lines of code. DOH !! lol

    What keeps me interested in the project is that I know someone will use it and it is custom designed for them so they like it a lot. The downside is I'm the only coder and I have to generate all the reports (as well as manage the networks, computers, and be a DBA for two companies).

    I guess I love being a geek. :laugh:
    More beer please.

    @Brandenburg : With the compile optimizations that occur, the .Net languages are all pretty close in execution speed.
     
    10 Year Member at TPU
  11. W1zzard

    W1zzard Administrator Staff Member

    Joined:
    May 14, 2004
    Messages:
    16,595 (3.49/day)
    Thanks Received:
    17,118
    streetfighter 2 says thanks.
    10 Year Member at TPU
  12. PVTCaboose1337

    PVTCaboose1337 Graphical Hacker

    Joined:
    Feb 1, 2006
    Messages:
    9,501 (2.30/day)
    Thanks Received:
    1,144
    Location:
    Dallas, Texas
    Do you count "}" and similar as a line of code? If so I would imagine that is about 20% of the code.
     
    10 Year Member at TPU
  13. Kreij

    Kreij Senior Monkey Moderator Staff Member

    Joined:
    Feb 6, 2007
    Messages:
    13,817 (3.67/day)
    Thanks Received:
    5,628
    Location:
    Cheeseland (Wisconsin, USA)
    Heck yeah you count the "}" lines. Bragging rights you know. lol
     
    10 Year Member at TPU
  14. xbonez New Member

    Joined:
    Nov 29, 2010
    Messages:
    1,182 (0.50/day)
    Thanks Received:
    315
    Location:
    Philly, PA (US)
    If you're counting physical lines, you count everything including {s. Some people prefer a count of logical lines, in which case the count is a lot lesser.
     
  15. Kreij

    Kreij Senior Monkey Moderator Staff Member

    Joined:
    Feb 6, 2007
    Messages:
    13,817 (3.67/day)
    Thanks Received:
    5,628
    Location:
    Cheeseland (Wisconsin, USA)
    It really doesn't matter unless you are getting paid by lines of code.
    I'm not, so for me it's just an eye opener to see how much work I've actually done.
    Sort of a personal best kind of thing since I am not competing with anyone.

    A little off topic, but it's interesting to examine projects from a dependancy view.
    What I mean is that both W1zz's GPU-Z and my ERP program (although private) have outlived many multi-million dollar game budgeted productions.
    People (whether many or a few) who depend on your work keep it alive and create a continual need for it to be robust and adaptive for a changing environment, which in turn requires you as a programmer to adapt to those needs in your code.
    As a coder, there is no better feeling than when someone says, "It's just what I needed/wanted, well done."
     
    10 Year Member at TPU
  16. PVTCaboose1337

    PVTCaboose1337 Graphical Hacker

    Joined:
    Feb 1, 2006
    Messages:
    9,501 (2.30/day)
    Thanks Received:
    1,144
    Location:
    Dallas, Texas
    Because I went off topic I'll give you some ideas of what I did for fun:

    -I made a RAR and JPG combiner, which would hide RAR's in JPG files. Worked faster than cmdprompt.

    -I made a hidden RAR finder. I then tested it by lurking 4chan and downloading 1000 pictures. I found a WHOLE bunch of hidden RARs. And a whole bunch of porn inside them. '

    -I made a program to put up a wall between the router and the internet. Pretty much it would redirect the router to thinking the internet was coming from an imaginary place. Therefore it would not work. I did this on my router, not the schools.

    -I made a program in order to automatically broadcast the TPU recent posts to login window in Windows. This does still not work as it should.

    Kinda fun to mess around with good and evil, as long as you have access to things to test on, with permission. Or just buy your own gear.

    I also was messing with a little AI stuff, but I was unable to get too far with my limited understanding of structures of logic.
     
    10 Year Member at TPU
  17. Brandenburg

    Brandenburg New Member

    Joined:
    Feb 13, 2011
    Messages:
    171 (0.07/day)
    Thanks Received:
    31
    Location:
    Waco,Texas
    Only mentioned the lines of code on my "small" project because its in VB which does a lot of things for you so theoretically it should be less lines. In my experience C++ takes a minimum of 4 times the amount of code to do a windows program than VB...i.e. Not Console.. In the game im writting.. I exclusively use classes,properties,enumerators and several functions that are reused 1000's of times.. In other words.. Its written very lean and IMO efficient... Its so well organized that once the groundwork was laid out.. everything just fell into place..To me.. Its a work of art in code..

    Ill post some snapshots of it tomorrow in a new thread.. I'm sure some will laugh but it works and the forms are laid out pretty good.. Still haven't decided on a few things though...Its perhaps 50% done

    here is a screenshot of a program I did for my physics instructor that earned me a +10 on a test.. Just did it because I was bored.. I showed it to him in a impromptu meeting.. and he loved it.. asked me to make a few changes.. mainly with the calculations of the 4th quadrant as in certain situations... it would calculate the wrong value
    [​IMG]

    Next project will be an automatic catalog program for my movies/music on my PC..Never scanned folders before.. Will be very new to me

    My suggestion to the OP is to make a "tool" that has a legitimate use for him...and sorry for mildly hijacking your thread
     
  18. Maelstrom

    Joined:
    Sep 10, 2008
    Messages:
    532 (0.17/day)
    Thanks Received:
    159
    Location:
    VA/PA
    It's all good. Started my E.R.O program, and its proving difficult to transform what I do when solving these problems (which is a lot of comparisons, multiplication, addition, and subtraction between the rows of matrices) into code. Granted, c++ probably isn't the best language to do what I'm doing, but I'm still going to go for it anyways xD
     
  19. xbonez New Member

    Joined:
    Nov 29, 2010
    Messages:
    1,182 (0.50/day)
    Thanks Received:
    315
    Location:
    Philly, PA (US)
    After you're done with it, you could try porting it to a C# Winforms app so you can have a nice GUI too
     
  20. Kreij

    Kreij Senior Monkey Moderator Staff Member

    Joined:
    Feb 6, 2007
    Messages:
    13,817 (3.67/day)
    Thanks Received:
    5,628
    Location:
    Cheeseland (Wisconsin, USA)
    If he's using Visual C++ he has access to all the same GUI classes as Visual C# does.
    You get even more control if you write the GUI in WPF using XAML, but it's kind of a pain in the ass. Very powerful though.
     
    Last edited: Feb 18, 2011
    10 Year Member at TPU
  21. W1zzard

    W1zzard Administrator Staff Member

    Joined:
    May 14, 2004
    Messages:
    16,595 (3.49/day)
    Thanks Received:
    17,118
    not in "normal" unmanaged c++ using mfc
     
    10 Year Member at TPU
  22. Kreij

    Kreij Senior Monkey Moderator Staff Member

    Joined:
    Feb 6, 2007
    Messages:
    13,817 (3.67/day)
    Thanks Received:
    5,628
    Location:
    Cheeseland (Wisconsin, USA)
    I haven't done much in C++ lately.
    Visual C++ 2010 is still unmanaged code without Win32 wrappers and completely allows for unsafe code, no?
     
    10 Year Member at TPU
  23. Maelstrom

    Joined:
    Sep 10, 2008
    Messages:
    532 (0.17/day)
    Thanks Received:
    159
    Location:
    VA/PA
    OK, so I just finished my E.R.O program. Just a little over 300 lines (I know that is nothing, but I'm still impressed by it :roll:). It can also add/subtract and multiple matrices! I had thought it would take me longer, oh well. Now, I gotta pick a new project :toast:.

    Also, do you think I could post my code to have some of ya'll look at it? So ya'll can critique it, and such. Just as a reference point for what I know, I've read this tutorial up to pointers, have a little experience in Java from my AP comp sci class, and a little other c++ knowledge from googling.

    Edit: realized a weakness in the code, need to fix it, but I'll go ahead and post it (dealing with division by zero for the E.R.O part).
     
    Last edited: Feb 20, 2011
    Brandenburg says thanks.
  24. Brandenburg

    Brandenburg New Member

    Joined:
    Feb 13, 2011
    Messages:
    171 (0.07/day)
    Thanks Received:
    31
    Location:
    Waco,Texas
    Post away.. :toast:
     
  25. Maelstrom

    Joined:
    Sep 10, 2008
    Messages:
    532 (0.17/day)
    Thanks Received:
    159
    Location:
    VA/PA
    Here it is, would probably be easier to read to just c-n-p it to a doc or something: Edit: Fixed the division by zero issue (i think), just had to add two if statements.
    Code:
    /*
     * File:   main.cpp
     * Author: Maelstrom
     *
     * Created on February 18, 2011, 2:25 PM
     */
    
    #include <cstdlib>
    #include <iostream>
    #include <sstream>
    #include <vector>
    
    /*
     * This program asks the user to enter a matrix, and then offers the user a number of operations the user can do to the matrix they
     * entered. The program starts off by having the user input the dimensions of the matrix. Then, it asks for each element of the matrix. Current
     * operations the user can can select are addition, subtraction, and multiplication.  E.R.O will be added in the future.
     */
    void add(std::vector < std::vector <double> >, int, int); //will add two matrices, one of which is a parameter.
    void e_r_o(std::vector < std::vector <double> >, int, int);
    void multi(std::vector < std::vector <double> >, int, int); //will multiple two matrices, one of which is a parameter.
    void print(std::vector < std::vector <double> >, int, int); //prints out the matrix.
    
    int main() {
        std::cout << "Welcome to the Matrix manipulation program! This program can do a number of different mathmatical operations to matrices"
                " including Gaussian elimination. ";
        std::cout << "Please enter the dimensions and the elements of the matrix. Once completed"
                ", you will be given a number of mathmatical operations that can be applied to the matrix. "
                "Note: if you wish to find the solutions to a linear system, make sure to include what the equations are equal to." << '\n';
        int column, row; //for dimensions of the mxn matrix.
        std::string input; //used to store all input.
        while (true) { //infinite loop, will on be exited out of when user enters appropriate info.
            std::cout << "Enter the number of rows for the matrix: "; //asks for # of rows.
            std::getline(std::cin, input); //takes input as a string
            std::stringstream convert(input); //enters string into the stringstream.
            if (convert >> row) { //checks if the input can be converted into a double. If it can, it enters the number into row.
                if (row != 0) { //can't go having a matrix with 0 rows
                    break; //exits out of loop.
                }
            }
            std::cout << "Error, please enter an appropriate number of rows." << '\n';
        }
        while (true) { //does the same as above, but for the number of columns.
            std::cout << "Enter the number of columns for the matrix: ";
            std::getline(std::cin, input);
            std::stringstream convert(input);
            if (convert >> column) {
                if (column != 0) {
                    break;
                }
            }
            std::cout << "Error, please enter an appropriate number of columns." << '\n';
        }
        std::vector <std::vector <double> > matrix; //creates a multidimensional vector. Used instead of an array for ease of parameterizing.
        matrix.resize(row);
        for (int i = 0; i < row; ++i) {
            matrix[i].resize(column);
        } //makes the vector the desired size by using .resize
        std::cout << "Please enter each element for the row." << '\n';
        int r = 0;
        while (r < row) { //asks user for the elements in each row of the matrix. Will repeat while r < row.
            int c = 0;
            std::cout << "Row " << r + 1 << ": ";
            std::getline(std::cin, input);
            std::stringstream convert(input);
            while (true) { //loops indefinately, until each element has a double.
                if (convert >> matrix[r][c]) { //checks to see if input can be converted into a double
                    ++c; //moves to next column
                }
                else {
                    break;
                }
                if (c == column) { //once the last column has a double, will break out of while loop.
                    ++r; //moves to next row
                    break;
                }
            }
        }
        while (true) { //asks user to select which operation they would like to do to the matrix.
            std::cout << "Select which operation you would like to use on the matrix. " << '\n';
            std::cout << "0) Print matrix" << '\n';
            std::cout << "1) Matrix addition and subtraction" << '\n';
            std::cout << "2) Matrix multiplication" << '\n';
            std::cout << "3) Gaussian elimination" << '\n';
            std::cout << "Selection? ";
            std::getline(std::cin, input);
            std::stringstream convert(input);
            int selection;
            if (convert >> selection) {
                if (selection == 0) { //allows user to print their matrix in all its glory!
                    print(matrix, row, column);
                    break;
                }
                else if (selection == 1) {
                    add(matrix, row, column); //calls the add function, which will add to user inputed matrices.
                    break; //breaks out of infite while loop.
                }
                else if (selection ==2 ) {
                    multi(matrix, row, column);
                    break;
                }
                else if (selection == 3) {
                    e_r_o(matrix, row, column);
                    break;
                }
            }
            std::cout << "Please enter an appropriate selection." << '\n';
        }
        std::cout << "Would you like to rerun the program?" << std::endl; //gives user the option to rerun program by using recursion.
        std::cout << "Y/N? ";
        std::getline(std::cin, input);
        if (input == "y" || input == "Y") {
            return main();
        }
        return 0;
    }
    /*
     * Allows for the addition and subtraction, based on user choice, of two matrices. The first one is taken from the main, along with
     * the row and column length of the first matrix. Using a multidimensional vector, a second matrix is made with the same dimensions
     * as the first matrix. User is then asked to input each element. Finally, the matrices are either added or subtracted, and then
     * the result is printed out, using the print function.
     */
    void add(std::vector < std::vector <double> > nom, int row, int column) {
        std::cout << "Please enter the elements for the row. Note: in order to add or subtract matrices, the dimensions of both must be the same."
                " The dimensions of the first matrix you entered will be used for this one." << '\n';
        //using same method to acquire details of second matrix.
        std::string input;
        std::vector <std::vector <double> > nom2;
        nom2.resize(row);
        for (int i = 0; i < row; ++i) {
            nom2[i].resize(column);
        }
        int r = 0;
        while (r < row) {
            int c = 0;
            std::cout << "Row " << r+1 << ": ";
            std::getline(std::cin, input);
            std::stringstream convert(input);
            while (true) {
                if (convert >> nom2[r][c]) {
                    ++c;
                }
                else {
                    break;
                }
                if (c == column) {
                    ++r;
                    break;
                }
            }
        }
        std::cout << "Addition or subtraction? "; //user can chose to add or subtract.
        std::getline(std::cin, input);
        if (input == "Add" || input == "add" || input == "Addition" || input == "addition") {
            for (int i = 0; i < row; ++i) {
                for (int j = 0; j < column; ++j) {
                    nom [i][j] += nom2 [i][j]; //adds each corresponding element of the two matrices together. Goes row by row.
                }
            }
            print(nom, row, column);
        }
        else if (input == "Subtract" || input == "subtract" || input == "Subtraction" || input == "subtraction") {
            for (int i = 0; i < row; ++i) {
                for (int j = 0; j < column; ++j) {
                    nom [i][j] -= nom2 [i][j]; //same as above, just with subtraction.
                }
            }
            print(nom, row, column);
        }
        else {
            std::cout << "Please choose to add or subtract." << '\n';
        }
    }
    /*
     * Uses Gaussian-Jordan elimination to put the matrix into the reduced row-echelon form. It then prints out the matrix.
     */
    void e_r_o(std::vector < std::vector <double> > nom, int row, int column) {
        //puts the matrix into row-echelon form.
        int a = 0, b = 0, c = 1;
        while (a < row - 1) {
            if (nom [a][b] != 0) {
                int y = 0;
                std::vector <double> holder;
                holder.resize(row - 1);
                for (int i = c; i < row; ++i) {
                    holder [y] = (nom [i][b]) / (nom [a][b]);
                    ++y;
                }
                int z = 0;
                for (int i = c; i < row; ++i) {
                    for (int j = b; j < column; ++j) {
                        nom [i][j] -= holder [z] * nom [a][j];
                    }
                    ++z;
                }
            }
            ++a;
            ++b;
            ++c;
        }
        //makes leading element for each row a leading one.
        for (int i = 0; i < row; ++i) {
            double k = nom [i][i];
            for (int j = 0; j < column; ++j) {
                nom [i][j] /= k;
            }
        }
        //makes the row-echelon formed matrix into a reduced row-echelon form.
        int d = row - 1, e = column - 2, f = row - 2;
        while (d > 0) {
            if (nom [d][e] != 0) {
                int y = 0;
                std::vector <double> holder;
                holder.resize(row - 1);
                for (int i = f; i > -1; --i) {
                    holder [y] = (nom [i][e]) / (nom [d][e]);
                    ++y;
                }
                int z = 0;
                for (int i = f; i > -1; --i) {
                    for (int j = (column - 1); j > -1; --j) {
                        nom [i][j] -= holder [z] * nom [d][j];
                    }
                    ++z;
                }
            }
            --d;
            --e;
            --f;
        }
        print (nom, row, column);
    }
    /*
     * Multiplies two matrices together, and then prints out the product. Gets the first matrix from the parameter, and the second
     * is created by the user.
     */
    void multi(std::vector < std::vector <double> > nom, int row1, int column1) {
        std::cout << "Please enter the dimensions of the second matrix. Note: The number of columns of the first matrix must "
                "equal the number of rows of the second matrix." << '\n';
        std::string input;
        int row2, column2;
        while (true) { //asks for number of rows. Checks to make sure it equals the number of columns in the first matrix.
            std::cout << "Number of rows (must be same as number of columns of first matrix!): ";
            std::getline(std::cin, input);
            std::stringstream convert (input);
            if (convert >> row2) {
                if (row2 == column1) {
                    break;
                }
            }
            std::cout << "Please enter an appropriate value." << '\n';
        }
        while (true) { //asks for number of columns.
            std::cout << "Number of columns: ";
            std::getline(std::cin, input);
            std::stringstream convert (input);
            if (convert >> column2) {
                if (column2 != 0) {
                    break;
                }
            }
            std::cout << "Please enter an appropriate value." << '\n';
        }
        std::vector < std::vector <double> > nom2; //creates the second matrix based off the entered dimensions.
        nom2.resize(row2);
        for (int i = 0; i < row2; ++i) {
            nom2[i].resize(column2);
        }
        std::cout << "Please enter the elements for each row." << '\n';
        int r = 0;
        while (r < row2) { //User enters each element for each row. Has checks in place to make sure user enters doubles.
            int c = 0;
            std::cout << "Row " << r+1 << ": ";
            std::getline(std::cin, input);
            std::stringstream convert(input);
            while (true) {
                if (convert >> nom2[r][c]) {
                    ++c;
                }
                else {
                    break;
                }
                if (c == column2) {
                    ++r;
                    break;
                }
            }
        }
        std::vector < std::vector <double> > nom3; //creates a third matrix to hold of the values of other two matrices multiplied.
        nom3.resize(row1); //has row1 rows, and column 2 columns.
        for (int i = 0; i < row1; ++i) {
            nom3[i].resize(column2);
        }
        /*
         * Algorithm for multiplying the two matrices. Multiples the corresponding element of the ith row of the 1st matrix and jth column
         * of the 2nd matrix. Adds them together, and places the final number into the a(i,j) element of the product matrix.
         */
        int z = 0;
        while (z < row1) {  //Z is used to track the row number for the 3rd and 1st matrix. Stops once it equals row1.
            for (int a = 0; a < column2; ++a) { //Used to track the column of the 3rd and 2nd matrix. Stops once it equals column2.
                for (int b = 0; b < row2; ++b) { //Used to track the column for the 1st matrix, and the row for the 2nd matrix.
                    nom3[z][a] += nom[z][b] * nom2[b][a]; //Multiplies the elements together, then adds the product to the corresponding element in nom3.
                }
            }
            ++z;
        }
        print(nom3, row1, column2);
    }
    
    /*
     * Prints each element of the matrix.
     */
    void print(std::vector < std::vector <double> > nom, int row, int column) {
        for (int i = 0; i < row; ++i) {
            for (int j = 0; j < column; ++j) {
                std::cout << nom[i][j] << " ";
            }
            std::cout << std::endl;
        }
    }
     
    Last edited: Feb 20, 2011
    streetfighter 2 says thanks.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guest)