Home > Back-end >  Save the children, don't write their own operation, I want to see
Save the children, don't write their own operation, I want to see

Time:11-30

1. Write a program to each row number five output all the leap year 1900-2000, required to write a function to determine whether one leap year, the main function calls the function, the function
Tip:
The called function:
Functions: to determine whether one leap year
Function parameters: int year
() function returns the inverse return value is 1, 0 the called function is not the prototype: int leap (int year) main function:
Call the leap () function, judging from 1900 to 2000 is a leap year, if it is, the output and count, 5 number per line output,
Note: the called function function just judge whether one year is a leap year, the output to the main function is complete,

CodePudding user response:

 
During int leap (int)
{
//ordinary years can be divided exactly by 4 and can't be divided exactly by 100 is a leap year
//century years divisible by 400 is a leap year
Return (((year % 4)==0) & amp; & ((year 100) %! %=0)) | | (year 400)==0).
}



CodePudding user response:

#include
During int leap (int)
{
If ((year % 4==0 & amp; & Year % 100!=0) | | (400 year %==0))
return 1;
The else return 0;
}
Int main ()
{
Int year, I=0;
For (year=1900; Year & lt;=2000; Year + +)
{
If (leap) (year)
{
I + +;
Printf (" % d \ t ", year);
If (I % 5==0)
printf ("\n");
}
}
printf ("\n");
return 0;
}
The format code on mobile phones, some characters may not right, right to revise the input is completed,
  • Related