1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
double NH, NB, NS, NT, VH, VB, VS, VT,VHS,VBS,VSS, i, VC, PH, PB, PS, profit, PI, per_H, per_B, per_S,order_H,order_B,order_S,first,second,third;
PI=3.1415926;
ifstream infile;
infile.open("Batch_03.txt");
i=0;
while (infile>>NH>>NB>>NS)
{
i++;
NT=NH+NB+NS;
PH=NH/NT;
PB=NB/NT;
PS=NS/NT;
if (PH>=0.1&&PB>=0.1&&PS>=0.1)
{
VHS=PI*10*10*10/(12*12*12);
VBS=8*10*18/(12*12*12);
VSS=7*7*12/(12*12*12);
VH=NH*VHS;
VB=NB*VBS;
VS=NS*VSS;
VT=(VH+VB+VS)*1.12;
VC=10*11*12;
if (VT<=VC)
{
per_H=2.75/VHS;
per_B=3.19/VBS;
per_S=1.07/VSS;
if (per_H<per_B&&per_H<per_S&&per_B>per_S)
{
order_H=third;
order_S=second;
order_B=first;
}
if (per_H<per_B&&per_H<per_S&&per_B<per_S)
{
order_H=third;
order_B=second;
order_S=first;
}
if (per_H<per_B&&per_H>per_S)
{
order_S=third;
order_H=second;
order_B=first;
}
if (per_H>per_B&&per_H>per_S&&per_B>per_S)
{
order_S=third;
order_B=second;
order_H=first;
}
if (per_H>per_B&&per_H<per_S)
{
order_B=third;
order_H=second;
order_S=first;
}
if (per_H>per_B&&per_H>per_S&&per_S>per_B)
{
order_B=third;
order_S=second;
order_H=first;
}
cout<<"The order of giving away of hat is "<<order_H<<" The order of giving away of boots is "<<order_B<<" The order of giving away of shillelaghs is "<<order_S;
}
else
{
cout<<"Batch "<<i<<"works"<<endl;
profit=2.75*NH+3.19*NB+1.07*NS;
cout<<"the profit is "<<profit<<endl;
}
}
else
{
cout<<"not enough amount"<<endl;
}
}
system ("pause");
return 0;
}.
|