Attacked by various csdn bulls... continue to cheer...
Today I flipped through "programming Pearl River". In fact, this book is still a bit deep to myself and cannot be eaten.
A small question isCalculate the number of days in the two days;
It happens that the same problem occurs when you do web jobs a few days ago. However, if you call system functions directly for that question, the two dates minus/1000/60/60/24 is the number of days;
In c, I really don't know if there are such powerful functions. If so, let me know;
Let's talk about what I implemented. I gave two dates, respectively, to find the number of days that have elapsed since the first year of the current year, and then subtract from each other, that is, the number of days of the difference (both positive and negative, everyone understands );
/*********** 2013-12-30 * _ Luffy * http://blog.csdn.net/xjm199?##########/#include
Int isleapyear (int year) // whether it is a leap year {return (year % 4 = 0 & year % 100! = 0) | year % 400 = 0);} int sum (int year, int month, int day) {int mon [] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int sum = (year-1) * 365; // Number of days since the first year of the current year int I; sum + = (year-1)/4 + 1; // sum-= (year-1)/100 + 1 can be added to all the four divisible items; // The sum + = (year-1) of the 100 divisible items is not the sum + = (year-1) of the leap year) /400 + 1; // The Real divisible by 400 is the leap year for (I = 0; I <month-1; ++ I) // Add sum + = mon [I] to the remaining month of the current year; if (isleapyear (year) = 1 & month> 2) // do you want to renew this year on April 9, February + sum; sum + = day; // Add return sum on the day of this month;} int main () {printf ("% d \ n ", sum (2013, 11, 1)-sum (2013, 9, 30); return 0 ;}
Sum is the day since the first year of the year;
The result is as follows:
32Process returned 0 (0x0) execution time : 0.331 sPress any key to continue.
Welcome to mention... o (∩ _ ∩) o