Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. // Date.cpp : Defines the entry point for the console application.
  2. //exercises: 1-5.
  3.  
  4. #include "stdafx.h"
  5. #include "../../../../std_lib_facilities.h"
  6.  
  7. using namespace std;
  8.  
  9. struct Date {
  10.     int y; //rok
  11.     int m; //miesiąc
  12.     int d; //dzień
  13. };
  14.  
  15. //Funkcje Pomocnicze:
  16.  
  17. void init_day(Date& dd, int y, int m, int d)
  18. {
  19.     if (dd.y < 0) error("Y");
  20.     dd.y = y;
  21.     if (dd.m > 12 || dd.m < 1) error("m");
  22.     dd.m = m;
  23.     if (dd.d > 31 || dd.m < 1) error("d");
  24.     dd.d = d;
  25. }
  26.  
  27. void add_day(Date& dd,int n)
  28. {
  29.     ;
  30. }
  31.  
  32. void f()
  33. {
  34.     Date today;
  35.         init_day(today,1978,7,20);
  36.         add_day(today, 1);
  37. }
  38.  
  39. ostream& operator<<(ostream& os, Date d)
  40. {
  41.     return os << Date();
  42. }
  43. int main()
  44. try{
  45.     Date today;
  46.     init_day(today, 1978, 7, 20);
  47.     cout << today.y<<", "<<today.m<<","<<today.d<<endl;
  48.     cout << today;
  49.     //Date tommorow;
  50. }
  51. catch (exception& e) { cerr << e.what(); }
  52. catch (...) { cerr << "Exception: "; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement