//This file is main.C #include #include #include "date.h" using namespace std; int main() { const int len[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int status = EXIT_SUCCESS; int n1 = 0; for (int year1 = 1901; year1 <= 1905; ++year1) { cout << year1 << "\n"; //assure the user that we're making progress for (int month1 = 1; month1 <= 12; ++month1) { for (int day1 = 1; day1 <= len[month1]; ++day1, ++n1) { const date d1(month1, day1, year1); int n2 = 0; for (int year2 = 1901; year2 <= 1905; ++year2) { for (int month2 = 1; month2 <= 12; ++month2) { for (int day2 = 1; day2 <= len[month2]; ++day2, ++n2) { const date d2(month2, day2, year2); const date mid = midpoint(d1, d2); const int dist1 = distance(d1, mid); const int dist2 = distance(mid, d2); int discrepancy = dist1 - dist2; if (discrepancy < 0) { discrepancy = -discrepancy; } if (discrepancy > 1) { cout << "Distance from "; d1.print(); cout << " to "; mid.print(); cout << " is " << dist1 << ".\n"; cout << "Distance from "; mid.print(); cout << " to "; d2.print(); cout << " is " << dist2 << ".\n"; status = EXIT_FAILURE; goto done; } } } } } } } done:; return status; }