Created
February 27, 2014 16:42
-
-
Save bitwiser/9253891 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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