Sie sind auf Seite 1von 3

PROGRAM:-LAPLACE

ROLL NO:-42
CODING:#include<iostream.h>
#include<conio.h>
class laplace
{
int a[10][10],avg[10],sn,max,coa,EP,add,maxp;
public:
void getdata();
void calculate();
void show();
};
void laplace::getdata()
{
cout<<"Enter No. of the State of Nature::";
cin>>sn;
cout<<endl<<"Enter No. of the Course of Action::";
cin>>coa;
cout<<endl<<"Enter the values(payoff) Of matrix("<<sn<<"*"<<coa<<")::";
for(int i=1;i<=sn;i++)
{
for(int j=1;j<=coa;j++)
{
cin>>a[i][j];
}
}
clrscr();
}
void laplace::calculate()
{
EP=coa;
add=0;
for(int i=1;i<=sn;i++)
{
for(int j=1;j<=coa;j++)
{
add=add+a[i][j];
}
avg[i]=add/EP;
add=0;
//cout<<avg[i]<<endl;
}

max=0;
for(i=1;i<=sn;i++)
{
if(max<avg[i])
{
max=avg[i];
maxp=i;
}
}
}
void laplace::show()
{
for(int p=1;p<=coa;p++)
cout<<"\t"<<"S"<<p;
cout<<"\t"<<"Average";
cout<<endl;
for(int i=1;i<=sn;i++)
{
cout<<"N"<<i<<"\t";
for(int j=1;j<=coa;j++)
{
cout<<a[i][j]<<"\t";
}
cout<<avg[i];
cout<<"\n";
}
cout<<endl<<"Maximum Avg is::"<<max;
cout<<endl<<"Therefore We adopt N"<<maxp<<" strategy";
}
void main()
{
laplace obj;
clrscr();
obj.getdata();
obj.calculate();
obj.show();
getch();
}
OUTPUT:Enter No. of the State of Nature::3

Enter No. of the Course of Action::3


Enter the values(payoff) Of matrix(3*3)::7000 5000 3000 3000 4500 3000 3000 3000
3000

N1
N2
N3

S1 S2
S3 Average
7000 5000 3000 5000
3000 4500 3000 3500
3000 3000 3000 3000

Maximum Avg is::5000


Therefore We adopt N1 strategy

Das könnte Ihnen auch gefallen