Home > Back-end >  Urgent urgent
Urgent urgent

Time:09-26

#include
# include "stdio.h"
using namespace std;

Struct MyDate//define a structure, storage date
{
Int m_year;//the year
Int m_month;//in
Int m_day;//day
};
Void main () {
MyDate computePrevDate (MyDate date)//calculation on the date of the day
{
MyDate prev=new MyDate ();//will be assigned to the date of today yesterday
Prev. M_year=date. M_year;
Prev. M_month=date. M_month;
Prev. M_day=date. M_day;
Int lastday=28;//a month late date
If (date. M_month % 2==1 & amp; & The date, m_month & lt; 8) | | (date. M_month % 2==0 & amp; & The date, m_month & gt;=8))
Lastday=31;
If (date. M_month==4 | | date. M_month==6 | | date. 9 m_month==| | date. M_month==11)
Lastday=30;

In February the else {//
If (date. M_year % 4==0 & amp; & The date m_year % 100!=0) | | date. M_year %==0)//400 is a leap year
Lastday=29;
The else//is not a leap year
Lastday=28;
}

//if the date is the first day of this month, the day is the last day of last month, otherwise it is ordinary date
If (date. M_day==1)//early date
{
Prev. M_day=lastday;
If (date. M_month==1)//at the beginning of the year date
{
Prev. M_month=12;
Prev. M_year -;
}
The else
{//early date
Prev. M_month -;
}
}
The else//ordinary date
{
Prev. M_day -;
}
Return prev.
}


}






//have been submitted to the error C2601: 'computePrevDate' : the local function definitions are illegal

CodePudding user response:

ComputePrevDate function definition, on the outside of the main function, the C/C + + function definition may not be nested directly,
  • Related