PROGRAM FOR MAXIMIN CRITERIA

SOURCE CODE :

//programed by Paras Wadher
MCA
Nagpur university

//Program for Maximin criteria
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
class maximin
{
private :
int A[100][100],i,j,m,n,r,r1;
int small,s[100],large;
public :
void getdata(void);
void disp(void);
};
void maximin :: getdata(void)
{
cout<<“\n\n\t Enter the size of Matrix… “;
cout<<“\n\n\t Number of row’s : “;
cin>>m;
cout<<“\n\n\t Number of col’s : “;
cin>>n;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cout<<“\n\n\t Enter the value for row “<<i+1<<” : “;
cin>>A[i][j];
}
}
}

void maximin :: disp(void)
{
small = 9999;
for(i=0;i<m;i++)
{
small = 9999;
for(j=0;j<n;j++)
{
if(small<=A[i][j])
{
small = small;
s[i] = small;
}
else
{
small = A[i][j];
s[i] = small;
}
}
}

large = s[0];
for(i=0;i<m;i++)
{
if(large>=s[i])
large = large;
else
large = s[i];
}

for(i=0;i<m;i++)
{
if(s[i] == large)
r = i+1;
}

cout<<“\n\n\t Your entered matrix is :\t\t Minimum”;
cout<<“\n\n\t\t\t”;
for(i=0;i<m;i++)
{
cout<<” A”<<i+1<<” –>”;
for(j=0;j<n;j++)
{
cout<<” “<<setw(4)<<A[i][j];
}
cout<<” “<<s[i];
cout<<“\n\n\t\t\t”;
}
cout<<“\n\n\t The Maxmin (maximun of minimum) is “;
cout<<large<<” at row “<<r;
cout<<“\n\n\t Hence the answer is A”<<r<<” Alternatives.”;
}

void main()
{
clrscr();
maximin m;
m.getdata();
clrscr();
m.disp();
getch();
}

output :

Enter the size of Matrix…

Number of row’s : 3
Number of col’s : 3

Enter the value for row 1 : 8000
Enter the value for row 1 : 3500
Enter the value for row 1 : 5000

Enter the value for row 2 : 4500
Enter the value for row 2 : 4500
Enter the value for row 2 : 5000

Enter the value for row 3 : 2000
Enter the value for row 3 : 5000
Enter the value for row 3 : 4000

Your entered matrix is :
Minimum

A1 –> 8000 3500 5000 3500

A2 –> 4500 4500 5000 4500

A3 –> 2000 5000 4000 2000

The Maxmin (maximun of minimum) is 4500 at row 2

Hence the answer is A2 Alternatives.

Leave a Reply

Your email address will not be published. Required fields are marked *