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
|
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include <cmath>
#include <cstdio>
using namespace std;
int main() {
char c;
string line;
int numlines = 0, sum = 0,num, h,ze;
double b, S, T,time = 0.0;
string m,d,e,f,g,q,i,o,j,k,l,y,n,p,r,z,x,w;
double Tp = 0.0, Thput = 0.0,Throughput = 0.0;
ifstream myfile ("RN1-9.tr");
ofstream MYFILE("TvThr.tr");
ofstream MF("Bcheck.tr");
//ifstream myfile ("New1-9.tr");
if(myfile.is_open()) {
while (getline(myfile,line)) {
numlines++;
istringstream input(line);
input >> c >> b >> m >> d >> e >> f >> g >> h >> q >> i >> o >> j>> k;
if (b > 11.0 && b <21.0 ) {
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(9);
MF << "b=" << b << ".\n";
if (c== 'r')
sum = sum + h;
//cout << "sum =" << sum << ".\n";
switch (c)
{
case 's':
T = b;
break;
case 'r' :
S = b- T;
cout << "S(ze)= " << S << ".\n";
time = time + S;
cout << "Total Time =" << time << ".\n";
break;
}
}
Tp = sum * 8;
cout << "Bits =" << Tp << ".\n";
Thput = Tp /(time);
Throughput = Thput/1000000;
MYFILE << "10 " << " " << Throughput << "Mbps" <<".\n";
if (b > 21 && b <31.0 ) {
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(9);
MF << "b=" << b << ".\n";
if (c== 'r')
sum = sum + h;
//cout << "sum =" << sum << ".\n";
switch (c)
{
case 's':
T = b;
break;
case 'r' :
S = b- T;
cout << "S(ze)= " << S << ".\n";
time = time + S;
cout << "Total Time =" << time << ".\n";
break;
}
}
Tp = sum * 8;
cout << "Bits =" << Tp << ".\n";
Thput = Tp /(time);
Throughput = Thput/1000000;
MYFILE << "20 " << " " << Throughput << "Mbps" <<".\n";
}
myfile.close();
}
else cout << "Unable to open file";
return 0;
}
|