Commit 42d43804 authored by Jonathon Duerig's avatar Jonathon Duerig
Browse files

Added two programs to help in analyzing route statistics.

parent a210edb9
// add-x.cc
#include <iostream>
using namespace std;
int main()
{
double current = 0.0;
double total = 0.0;
cin >> current;
while (cin)
{
cout << total << ' ' << current << endl;
total += 0.01;
cin >> current;
}
return 0;
}
// difference.cc
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(int argc, char * argv[])
{
if (argc == 3)
{
ifstream ideal(argv[1], ios::in);
ifstream candidate(argv[2], ios::in);
ofstream relative((argv[2] + string(".relative")).c_str(),
ios::out | ios::trunc);
ofstream absolute((argv[2] + string(".absolute")).c_str(),
ios::out | ios::trunc);
if (ideal && candidate && relative && absolute)
{
int left = 0;
int right = 0;
ideal >> left;
candidate >> right;
while (ideal && candidate)
{
absolute << (right - left) << endl;
double num = right - left;
double denom = right;
if (right != 0)
{
relative << (num/denom) << endl;
}
ideal >> left;
candidate >> right;
}
}
}
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment