Skip to content

Instantly share code, notes, and snippets.

@bitwiser
Created February 27, 2014 16:42
Show Gist options
  • Save bitwiser/9253891 to your computer and use it in GitHub Desktop.
Save bitwiser/9253891 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <cfloat>
using namespace std;
int main()
{
const double C(299792458.0);
const int NUMBER_OF_SATELLITES (5);
int satID, minID;
double tTime, pRange, minPRange (DBL_MIN);
cout << "Enter id and transit time for "
<< NUMBER_OF_SATELLITES << " satellites:\n"
<< "Use whitespace to separate the values(ie: 25 0.00257)\n"
<< endl;
for(int i=1; i<=NUMBER_OF_SATELLITES; ++i)
{
cin >> satID >> tTime;
pRange = tTime*C;
if(pRange > minPRange)
{
minPRange = pRange;
minID = satID;
}
cout << "Satellite " << satID << " has a pseudorange of "
<< pRange << " m \n" << endl;
}
cout << "\nSatellite " << minID
<< " is closest to GPS receiver." << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment