E6: WRITE A PROGRAM FOR MINIMIN CRITERIA
#include<iostream.h>
#include<conio.h>
class minimin
{
private:
int i,j,r,c,a[10][10],p[10];
int min;
public:
void getdata();
void display();
void cal();
};
void minimin::getdata()
{
cout<<"\nEnter the row: ";
cin>>r;
cout<<"\nEnter the column: ";
cin>>c;
cout<<"\nEnter the matrix element:\n";
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
cin>>a[i][j];
}
}
}
void minimin::cal()
{
for(i=0;i<r;i++)
{
min=100;
for(j=0;j<c;j++)
{
if(a[i][j]<=min)
min=a[i][j];
}
p[i]=min;
}
min=100;
for(i=0;i<r;i++)
{
if(p[i]<=min)
min=p[i];
}
display();
cout<<"\n\nThe minimin value is :"<<min;
}
void minimin::display()
{
cout<<"\n\n\tTHE PAYOFF MATRIX IS:\n\n";
cout<<endl;
for(j=0;j<=c;j++)
cout<<"\t";
cout<<"MINIMIN"<<endl;
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
cout<<"\t"<<a[i][j];
}
cout<<"\t"<<p[i];
cout<<endl;
}
}
void main()
{
clrscr();
minimin k;
k.getdata();
k.cal();
k.display();
getch();
}
OUTPUT
Enter the row: 3
Enter the column: 4
Enter the matrix element:
8 0 -10 6
-4 12 18 -2
14 6 0 8
THE PAYOFF MATRIX IS:
MINIMIN
8 0 -10 6 -10
-4 12 18 -2 -4
14 6 0 8 0
The minimin value is :-10
No comments:
Post a Comment
This Blog helps you to learn basics to high level programming coding and practicals.
conceptual understanding