1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
#include<iostream>
#include<cassert>
using namespace std;
int main()
{
int day1,day2,month1,month2, validate_date1, validate_date2;
int daysPerMonth[12]={31,28,31,30,31,30,31,31,30,31,30,31};
const int Maximum_month = 12;
int Sum_of_date1 = 0;//,Sum_of_date2;
cout<<"Enter the First date : ";
cin>>day1>>month1;
cout<<endl;
cout<<"Enter the Second date : ";
cin>>day2>>month2;
cout<<endl;
validate_date1 = daysPerMonth[month1];
validate_date2 = daysPerMonth[month2];
assert(day1<= validate_date1 && day2 <= validate_date2 && month1 <= Maximum_month && month2 <= Maximum_month );
int counter = 0;
while (counter < 1)
{
if (counter == 0)
{
for(int i = 1; i <= daysPerMonth[month1] ; i++)
{
//my problem starts here
Sum_of_date1 += daysPerMonth[i + 1];
}
cout<<Sum_of_date1;
}
counter++;
}
|