Crossing, everyone, from today onwards, we talk about the large-scale couplet science fiction: C Chestnut, that is, C language examples. Gossip Hugh,
Words return to the positive turn. Let's talk about C language examples together!
Crossing, the last time we gave the novel an opening, this time we formally say the C example, this time to say the example is: to judge leap years.
Crossing, what is a leap year? This is the concept of geographical astronomy. If you do not understand, you go to Baidu, haha. I also stole a lazy.
Crossing, there are two ways to judge a leap year:
- If a year can be divisible by 4, but not divisible by 100, then this year is leap years.
- If the year can be divisible by 400, then this year is leap years.
Crossing see divide must think of division, in fact, the division in the C Program and Math division operation is not the same, C Program Division Transport
Only integers are taken, and decimals after the decimal point are discarded. For example: 5/3=1.666 .... This is the result of a mathematical operation, the result of a C program
is 1 because it discards 1 of the number of decimal parts behind it. So we can't use the division operation to judge leap years. How to judge? Crossing Mo Urgent.
In the C program provides the take-up operation, the operation symbol is%. The residual operation is to take out the remainder in the division operation. For example: 5/3 of the remainder is 2.
So the result of the 5%3 is 2. Let's think, what does this mean if the result of the operation is 0 after taking a number for the remainder operation?
"This means that the number can be divisible by another number." This crossing is right. For example, 4%2=0 can indicate that 4 can be divisible by 2. See
Officials, the words are here, and now you know how to judge a leap year.
Crossing, the text does not write code, detailed code in my resources, you can click on this link to download the use.
Crossing, we're going to talk about this in the case of a leap year. I want to know what the following example, and listen to tell.
Talk C Chestnut Bar (second time: C-language instance-judging leap years)