Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Christian Ballard
- //11-10-2016
- //Lab 9
- #include<iostream>
- #include<iomanip>
- #define WIDTH 4
- #define HEIGHT 3
- using namespace std;
- int matrix[HEIGHT][WIDTH]; //Might need to be local
- int main()
- {
- char m; //Decides what to do in the switch statement
- //Input
- for(int n; n < HEIGHT; n++)
- {
- for(int x; x < WIDTH; x++)
- {
- cin >> matrix[n][x];
- }
- }
- //Output
- for(int i; i < 9; i++)
- {
- for(int j; j<9; j++)
- {
- cout << matrix[i][j] << " ";
- }
- cout << endl << endl;
- }
- cout << "Print the matrix = P\nSum all of the elements = E\nShow the upper half = U\nShow middle row = M\nShow middle column = C\n";
- cin >> m;
- m = toupper(m);
- switch(m){
- case 'P':
- cout << "Print the matrix" << endl;
- break;
- case 'E':
- cout << "Sum all of the elements" << endl;
- break;
- case 'U':
- cout << "Show the upper half" << endl;
- break;
- case 'M':
- cout << "Show middle row" << endl;
- break;
- case 'C':
- cout << "Show middle column" << endl;
- break;
- default:
- cout << "ERROR" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment