Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- bool is_peak(int Mat[5][5] ,int Rows ,int Cols ,int i ,int j){
- bool flag = true;
- for(int k=0 ; k<Cols ; k++){
- if( Mat[i][k] > Mat[i][j] )
- flag = false;
- }
- return flag;
- }
- int main()
- {
- int Cols = 5 ,Rows = 5 ,Mat[5][5];
- cout << "Enter The Matrix : " << endl;
- for(int i=0 ; i<Rows ; i++){
- cout << "Enter The Elements OF the " << i + 1 << "th Row" << endl;
- for(int j=0 ; j<Cols ; j++){
- cin >> Mat[i][j];
- }
- }
- cout << endl << "---------------------------" << endl;
- cout << "Our Matrix : " << endl;
- for(int i=0 ; i<Rows ; i++){
- for(int j=0 ; j<Cols ; j++)
- cout << setw(4) << Mat[i][j];
- cout << endl;
- }
- int NumOFTests;
- cout << "Enter The Number OF Tests You Want :";
- cin >> NumOFTests;
- for(int Test = 0 ; Test < NumOFTests ; Test++){
- int i ,j;
- cout << "Chose The Row and The Col Of Your Element : ";
- cin >> i >> j;
- if( is_peak(Mat ,Rows ,Cols ,i ,j) == true )
- cout << "is true ( Is Largest )" << endl;
- else
- cout << "is false ( Is Not Largest )" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment