PROGRAM for MAXIMAX CRITERIA

SOURCE CODE :

//programed by Paras Wadher
MCA
Nagpur university

//PROGRAM TO FIND THE VALUE BY USING MAXMAX CRITERIA

#include<iostream.h>
#include<conio.h>
class max
{
int c[10][10],max[10];
int i,j,m,n,maxval;
public:
void getdata();
void cal();

};
void max:: getdata()
{
cout<<“\n Enter the row size:”;
cin>>m;
cout<<“\n Enter the column size:”;
cin>>n;
cout<<“\n Enter the value of cost matrix”;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cin>>c[i][j];
}
}
}
void max::cal()
{
i=0;

while(i<m)
{
j=0;
max[i]=c[i][j];
for(j=0;j<n;j++)
{
if(max[i]<c[i][j])
{
max[i]=c[i][j];
}
}
i++;
}
cout<<“\n\n———————-\n\n”;
cout<<“cost matrix \t\t\t max value”;

cout<<“\n\n———————\n\n”;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cout<<c[i][j]<<“\t”;
}
cout<<“\t”<<max[i];
cout<<“\n\n”;
}
maxval=max[0];
for(i=0;i<m;i++)
{
if(maxval<max[i])
{
maxval=max[i];
}
}
cout<<“\n maximum from maximum values= “<<maxval ;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(maxval==c[i][j])
{
cout<<“\n A”<<i+1<<” is alternaive”;
}
}
}
}

void main()
{
clrscr();
max m;
m.getdata();
m.cal();
getch();
}

————-OUTPUT—————–

Enter the row size:3

Enter the column size:3

Enter the value of cost matrix
1 2 3
4 5 6
7 8 9

———————-

cost matrix max value

———————

1 2 3 3

4 5 6 6

7 8 9 9

maximum from maximum values= 9
A3 is alternaive

Leave a Reply

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