fork(2) download
  1. #include <iostream>
  2. #include <ctime>
  3. using namespace std;
  4.  
  5. int main() {
  6. tm date = { 0, 0, 18, 19, 5, 109, 0, 0, 0 };
  7. tm gregorian = { 0, 0, 0, 15, 9, (1582 - 1900), 0, 0, 0};
  8.  
  9. std::time_t th = std::mktime(&date);
  10. std::time_t tl = std::mktime(&gregorian);
  11. if (th==-1 || tl==-1) {
  12. std::cout<<"At least one of the date couldn't be converted"<<std::endl;
  13. }
  14. else {
  15. double aux = std::difftime(th, tl);
  16. std::cout << aux<< " "<< aux/3600.0/24.0/365.25 <<std::endl;
  17. std::cout << (aux>=0.0 ? "H>=L":"H<L") << std::endl;
  18. }
  19. return 0;
  20. }
Success #stdin #stdout 0s 4304KB
stdin
Standard input is empty
stdout
1.34647e+10 426.671
H>=L