Home > Back-end >  We can see what is the problem?
We can see what is the problem?

Time:09-25

We have a saying in China: three days fishing two days the net, someone beginning January 1, 1990 "three days fishing two days the net," asked the man in the later one day is in "fishing" or "net", input (date) (month) (year), output is in the "fishing" or on the "net" information,

Tip: need to take into account the issue of a leap year,

Requirements: must be conducted with function calls the program design,

During the int Leapyear (int) : write this function, is a leap year return 1, not 0

During the int CountDay (int, int the month, int day: write this function, return to the specified date from January 1, 1990 the number of days


#include

Int DaysPerMonth []=,31,28,31,30,31,30,31,31,30,31,30,31 {0};
{int Leapyear during (int)
If (year % 4==0 & amp; & Year % 100!=0 | | year %==0 400)
return 1;
return 0;
}

During the int CountDay (int, int the month, int day {
int i;
int sum=0;
For (I=1990; i If (Leapyear (I))
The sum +=366;
The else
The sum +=365;
}
For (I=1; i If (Leapyear (year))
DaysPerMonth [2]=29;
The sum +=DaysPerMonth [I];
}
The sum +=day;
Return the sum.

}



Int main (void) {
Int year, month, day.
Int TotalDay;
Printf (" please enter the specified date: y m d) ");
Scanf_s (" % d % d % d ", & amp; Year, & amp; The month, & amp; Day);
If (Leapyear (year))
DaysPerMonth [2]=29;
If (the month & lt; 1 | | month> 12 | | day<1 | | day> DaysPerMonth [month]) {
Printf (" input error! \n");
return 0;
TotalDay=CountDay (year, month, day);
If (TotalDay % 5 & gt;=1 & amp; & TotalDay % 5 & lt;
=3)Printf (" today fishing ");
The else
Printf (" today net ");

}
}

CodePudding user response:

 int main () 
{
Int year, month, day.
Int TotalDay;
Printf (" please enter the specified date: y m d) ");
Scanf_s (" % d % d % d ", & amp; Year, & amp; The month, & amp; Day);
If (Leapyear (year))
DaysPerMonth [2]=29;
If (the month & lt; 1 | | month> 12 | | day<1 | | day> DaysPerMonth [month]) {
Printf (" input error! \n");
return 0;
}//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- add braces on the right side -- -- -- -- -- -- -- -- -- -- --
TotalDay=CountDay (year, month, day);
If (TotalDay % 5 & gt;=1 & amp; & TotalDay % 5 & lt;
=3)Printf (" today fishing ");
The else
Printf (" today net ");

//-- -- -- -- -- -- -- -- -- -- -- -- the right brace remove -- -- -- -- -- -- -- -- -- -- -- --

return 0;
}

CodePudding user response:

reference 1st floor MianHou response:
 int main () 
{
Int year, month, day.
Int TotalDay;
Printf (" please enter the specified date: y m d) ");
Scanf_s (" % d % d % d ", & amp; Year, & amp; The month, & amp; Day);
If (Leapyear (year))
DaysPerMonth [2]=29;
If (the month & lt; 1 | | month> 12 | | day<1 | | day> DaysPerMonth [month]) {
Printf (" input error! \n");
return 0;
}//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- add braces on the right side -- -- -- -- -- -- -- -- -- -- --
TotalDay=CountDay (year, month, day);
If (TotalDay % 5 & gt;=1 & amp; & TotalDay % 5 & lt;
=3)Printf (" today fishing ");
The else
Printf (" today net ");

//-- -- -- -- -- -- -- -- -- -- -- -- the right brace remove -- -- -- -- -- -- -- -- -- -- -- --

return 0;
}

Thank you, I haven't found looked at half a day

CodePudding user response:

refer to the second floor ycm151 response:
Quote: refer to 1st floor MianHou response:
 int main () 
{
Int year, month, day.
Int TotalDay;
Printf (" please enter the specified date: y m d) ");
Scanf_s (" % d % d % d ", & amp; Year, & amp; The month, & amp; Day);
If (Leapyear (year))
DaysPerMonth [2]=29;
If (the month & lt; 1 | | month> 12 | | day<1 | | day> DaysPerMonth [month]) {
Printf (" input error! \n");
return 0;
}//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- add braces on the right side -- -- -- -- -- -- -- -- -- -- --
TotalDay=CountDay (year, month, day);
If (TotalDay % 5 & gt;=1 & amp; & TotalDay % 5 & lt;
=3)Printf (" today fishing ");
The else
Printf (" today net ");

//-- -- -- -- -- -- -- -- -- -- -- -- the right brace remove -- -- -- -- -- -- -- -- -- -- -- --

return 0;
}

Thank you for me to study all didn't find

You're welcome, I am also look for half a day before
  • Related