I plan to graduate school: The University of Beijing University of Technology-computer
Course Number 985: Textbook for C language programming case tutorials and Min data structure that book
Now begin to review the C language, plan to write the following part of the code to write the title once
Not regularly with the new one week later
======================== the second chapter &NBSP;C the basic control structure of the language ========================//==========4. Enter a year from the keyboard to determine whether the year is a leap years//====== ====5. Enter a year and month from the keyboard, and the number of days to output this month//========== simpler #include<stdio.h>//the days of the month Int daynum (Int year, int mouth) {int flag = 0;if ( year % 100 != 0 & & year % 4 == 0 ) | | ( year % 400 == 0)) flag = 1; // Leap Month if (mouth == 1 | | mouth == 3 | | mouth == 5 | | mouth == 7 | | mouth == 8 | | mouth == 10 | | &NBSP;MOUTH&NBSP;==&NBSP;12) return 31;else if (Mouth == 2 && flag) return 29;else if (Mouth == 2 && !flag) return 28;elsereturn 30;} Int main () {int year,mouth;scanf ("Enter any year:");while (scanf ("%d%d", &year,&mouth) == &NBSP;2) {if (year >= 0 && mouth > 0 && mouth <= &NBSP;12) {if ( year % 100 != 0 && year % 4 == 0 ) | | ( year % 400 == 0) ) printf ("%d is leap month \ t days are%d\n", Year,daynum (Year,mouth)); elseprintf ("%d is not leap month \ t days is%d\n", Year,daynum (Year,mouth));} elseprintf ("Hyper-range, re-enter \ n");} return 0;}
This article is from the "Rise" blog, please be sure to keep this source http://20111564.blog.51cto.com/6048168/1564609
C Language Programming Case Tutorial (second edition) answer