1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
#include <iostream>
#include <iomanip>
#define myRow 7
#define myClmn 7
using namespace std;
int x,y,sClmn,sRow,lRow,lClmn;
int main()
{double number;
cout<<"-----------------------------\nSolution for Assignment #7\n----------------------------\nSection #1: Display The Matrix\n";
int mymatrix[myRow][myClmn]={{2,5,6,3,5,9,1},{3,0,8,5,6,1,2},{6,4,9,6,5,2,3},{1,-4,2,5,1,0,4},{4,9,6,2,2,7,5},{7,1,6,9,8,9,6},{-2,-3,-4,5,-6,-7,7}};
for (int x=0; x<myRow; x++)
{
for(int y=0;y<myClmn;y++)
{ cout<<setw(14)<<mymatrix[x] [y]<<" ";
}
cout<<endl;
}
cout<<"\nSection #2: Get the input from the user\nEnter the number you would like to add: \n";
cin>> number;
cout<<"Define the section of a the matix to add the number";
cout<<"Please enter the starting cell address\nRow= ";
cin>>sRow;
cout<<"\nColumn: ";
cin>>sClmn;
cout<<"Please enter the ending cell address\nRow= ";
cin>>lRow;
cout<<"\nColumn: ";
cin>>lClmn;
for (x=sRow;x<lRow; x++)
{
for(y=sClmn; y<lClmn; y++)
{mymatrix [x][y]=mymatrix[x][y]+number;}
}
cout<<"Matrix after the process\n";
for(x=0; x<myRow; x++)
{
for(y=0; y<myClmn;y++)
cout<<setw(14)<<mymatrix [x][y];
cout<<endl;
}
cout <<"--------------------\nEnd of Assignment #7\n------------------------";
//system("pause");
return 0;
}
|