Home > Back-end >  How to change to input more than one year and then output together (date) (month) (year)?
How to change to input more than one year and then output together (date) (month) (year)?

Time:09-21

#include
Int main ()
{
Int year, month, day, t;
31,28,31,30,31,30,31,31,30,31,30 int mon [11]={};
int i=0;

The scanf (" % d ", & amp; t);
While (t -)
{
The scanf (" % d % d ", & amp; Year, & amp; Day);

If (year % 4==0 & amp; & Year % 100!=0 | | year %==0 400)
Mon [1] + +;

for (i=0; Day - mon [I] & gt; 0 & amp; & i<11. I++)
Day -=mon [I];

The month=I + 1;

Printf (" % d % d - % d \ n ", year, month, day);

If (mon [1]==29)
Mon [1] -;
}

return 0;
}

CodePudding user response:

Didn't quite understand what is the problem

CodePudding user response:

1. According to the input t new an array of objects, the object using a structure in the input, and day
Such as:
Srruct datatime
{
Int year;
Int the month;
}
PDT datatime *=new datatime [t];
2. Each cycle took out a set of data from the PDT
3. Remember to release the object finally processed data
The delete PDT;
PDT=nullptr;

CodePudding user response:

Then don't print the results in circulation, but the results in the array first, and then print the result of the array
  • Related