Skip to content

Instantly share code, notes, and snippets.

@digi0ps
Last active September 28, 2017 09:07
Show Gist options
  • Save digi0ps/8b37dfc11fa1f8e87320cc1b0a076948 to your computer and use it in GitHub Desktop.
Save digi0ps/8b37dfc11fa1f8e87320cc1b0a076948 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30 ,31};
class UDdate
{
int day;
int month;
int year;
public:
int operator-(UDdate&);
friend istream& operator>>(istream&,UDdate&);
friend ostream& operator<<(ostream&,UDdate&);
};
class med
{
int medid;
char name[20];
UDdate exp_Date;
public:
friend istream& operator>>(istream&,med&);
friend ostream& operator<<(ostream&,med&);
UDdate get_Date();
};
/* THIS IS THE CODE YOU NEED TO INSERT */
int no_of_days(int d, int m, int y){
int total;
total = (y-2000) * 365;
for(int i=0;i<(m-1);i++)
total+=days[i];
total += d;
return total;
}
int UDdate::operator-(UDdate& y){
int diff = no_of_days(day, month, year) - no_of_days(y.day, y.month, y.year);
}
istream& operator>>(istream& input, UDdate& d){
input>>d.day>>d.month>>d.year;
return input;
}
ostream& operator<<(ostream& output, UDdate& d){
output<<d.day<<endl<<d.month<<endl<<d.year;
return output;
}
istream& operator>>(istream& input, med& m){
input>>m.medid>>m.name>>m.exp_Date;
}
UDdate med::get_Date(){
return exp_Date;
}
ostream& operator<<(ostream& output, med& m){
output<<m.medid<<endl<<m.name<<endl;
}
/* STOP COPYING */
int main()
{
int num;
med e[20];
UDdate today_Date;
UDdate exp_Date;
int diff;
cin>>num;
for(int k=0;k<num;k++)
cin>>e[k];
cin>>today_Date;
for(int j=0;j<num;j++)
{
exp_Date = e[j].get_Date();
diff = exp_Date-today_Date;
if(diff < 31)
cout<<e[j];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment