Witaj,
wydaje mi się że do takiego zadania możesz użyć klasy i przeciążyć operator>>. Tutaj prosty przykład klasy Date, którą umożliwia zapisanie formatu dd.mm.yyyy:
#include <iostream>
using namespace std;
class Date {
static int lengths [12];
int day,month,year;
public:
Date ();
Date (int day,int month,int year);
Date &operator++ ();
friend bool operator< (const Date &first,const Date &second);
friend ostream &operator<< (ostream &stream,const Date &date);
friend istream &operator>> (istream &stream,Date &date); };
int Date::lengths [12]={31,28,31,30,31,30,31,31,30,31,30,31};
Date::Date (): day (),month (),year () {}
Date::Date (int day,int month,int year): day (day),month (month),year (year) {}
Date &Date::operator++ () {
lengths [1]=(year%4 ? 28 : 29);
if (++day>lengths [month-1]) {
day=1;
if (++month>12) {
month=1;
++year; }}
return *this; }
bool operator< (const Date &first,const Date &second) {
return first.year<second.year
|| (first.year==second.year && (first.month<second.month
|| (first.month==second.month && first.day<second.day))); }
ostream &operator<< (ostream &stream,const Date &date) {
return stream<<date.day<<'.'<<date.month<<'.'<<date.year; }
istream &operator>> (istream &stream,Date &date) {
char character;
stream>>date.day>>character>>date.month>>character>>date.year; }
int main () {
Date first,second;
cin>>first>>second;
for (int i=0;i<7;++i)
cout<<++(first<second ? second : first)<<endl;
return 0; }
Możesz później jeszcze użyć instrukcji if() do sprawdzenia czy wartości liczbowe są poprawne.
Pozdrawiam