steamengines

Lab9

Nov 9th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. //Christian Ballard
  2. //11-10-2016
  3. //Lab 9
  4.  
  5. #include<iostream>
  6. #include<iomanip>
  7. #define WIDTH 4
  8. #define HEIGHT 3
  9. using namespace std;
  10.  
  11. int matrix[HEIGHT][WIDTH]; //Might need to be local
  12.  
  13. int main()
  14. {
  15.     char m; //Decides what to do in the switch statement
  16.    
  17.     //Input
  18.     for(int n; n < HEIGHT; n++)
  19.     {
  20.         for(int x; x < WIDTH; x++)
  21.         {
  22.             cin >> matrix[n][x];
  23.         }
  24.     }
  25.     //Output
  26.     for(int i; i < 9; i++)
  27.     {
  28.         for(int j; j<9; j++)
  29.         {
  30.             cout << matrix[i][j] << " ";
  31.         }
  32.         cout << endl << endl;
  33.     }
  34.    
  35.     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";
  36.     cin >> m;
  37.     m = toupper(m);
  38.    
  39.    
  40.     switch(m){
  41.         case 'P':
  42.         cout << "Print the matrix" << endl;
  43.         break;
  44.         case 'E':
  45.         cout << "Sum all of the elements" << endl;
  46.         break;
  47.         case 'U':
  48.         cout << "Show the upper half" << endl;
  49.         break;
  50.         case 'M':
  51.         cout << "Show middle row" << endl;
  52.         break;
  53.         case 'C':
  54.         cout << "Show middle column" << endl;
  55.         break;
  56.         default:
  57.         cout << "ERROR" << endl;
  58.     }
  59.    
  60.    
  61.    
  62.    
  63.    
  64.    
  65.    
  66.    
  67.     return 0;
  68. }
Advertisement
Add Comment
Please, Sign In to add comment