help please
Hey guys im new to c++. Wondering if someone can help me with this code helping me generate succefull drops compared to not succesfull drops
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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
void first();
void second();
void showSum(int,int,int);
int main()
{
int counter,status=0, drop=0;
double s1,s2,s3, totalp;
srand(static_cast <unsigned>(time(0)));
cout<< "Enter how many drops";
cin >> drop;
system("cls");
cout<< setprecision(5)<< fixed;
first();
cout <<"\n"<<setw(15)<< "side1"<< setw(20)<< "Side2" << setw(20)<< "Side3" << setw(15) << " Status" << "\n\n\n";
for (counter=1; counter<=drop; counter++)
{
double m = static_cast <double> (rand()) / (static_cast <double> (RAND_MAX) + 1.0);
double b = static_cast <double> (rand()) / (static_cast <double> (RAND_MAX) + 1.0);
if(m > b)
{
s1 = b - 0;
s2 = m - b;
s3 = 1 - m;
}
else
{
s1 = m - 0;
s2 = b - m;
s3 = 1 - b;
}
if (s1 + s2 > s3 && s2 + s3 > s1 && s3 + s1 > s2)
{
cout <<"\n" << counter <<")" << setw(15) << s1 << setw(20) << s2 << setw(20) << s3 << setw(15) << "Triangle" << "\n";
status++;
}
else
cout << "\n" << counter <<")" << setw(15) << s1 << setw(20) << s2 << setw(20) << s3 << setw(15) << "Not" << "\n";
}
while(drop<=100
totalp = ((double)status / drop) * 100;
cout << setprecision(1) << fixed;
second();
showSum(status,drop,totalp);
cout << "\n\n\n Hit enter to continue....";
cin.ignore();
cin.get();
return 0;
}
void first()
{
cout<< "\t\t\t Matthew Baptiste\n";
}
void second ()
{
cout << "\n\n " << "Success" << setw(10) << "Drops" << setw(20) << "Probablity"<< setw(10);
}
void showSum(int status, int totalp, int drop)
{
cout << "\n\n " << setw(10) << status << setw(10) << drop << setw(20) << totalp << "% \n\n\n";
}
|
What is up with line 27 and 28?
Topic archived. No new replies allowed.