64 lines
1.3 KiB
C++

/*
* Primary interstate highway numbers are 1-99
* Odds go north/south
* evens go east/west
*
* Aux highways are 100-999
* Right most two digest are the primary highway it services
*
* givein a highway number, indicate primary or aux
* if aux indicate which highway it serves
*
* Also indicate if the primary highway runs north/south
* or east/west
*
* input: 90
* output: I-90 is primary, going east/west.
*
* input: 290
* output: I-290 is auxiliary, serving I-90, going east/west.
*
* input: 0
* output: 0 is not a valid interstate highway number.
*/
#include <iostream>
using namespace std;
int main() {
int highwayNumber;
string highwayDirection;
cin >> highwayNumber;
/* Type your code here. */
if (highwayNumber % 2 == 0){
highwayDirection="east/west";
}
else{
highwayDirection="north/south";
}
if ((highwayNumber < 1) ||
(highwayNumber > 999)){
cout << highwayNumber << " is not a valid interstate highway number.\n";
}
//Primary
else if (highwayNumber < 100){
cout << "I-" << highwayNumber << " is primary, going " <<
highwayDirection << ".\n";
//Aux
}
else{
cout << "I-" << highwayNumber << " is auxiliary, serving I-"<<
highwayNumber%100 << ", going " << highwayDirection << ".\n";
}
return 0;
}