Tuesday, May 31


Foundation C Program J
Topic: input irritating, judge this day is this year the number.how long?
1. The program analysis: to March 5, for example, should put the first two months of together, and then add five days namely upwards number.how long, specialSituation, leap year and input in more than 3 should be considered when additional day.

 2. The source code:
Main (){
Int/month, year, sum, leap,

Printf (" \ nplease input/month, year, \ n ");

 Scanf (" % d, % d, % d "year, month, & of& /); of&"Switch (month) / * first hour ago in calculating the total number of * /{Case 1: sum = 0, The;Case 2: sum = 31, The;Case 3: sum = 59, The;Case 4: sum = 90, The;Case 5: sum = 120; The;Case 6: sum = 151, The;Case 7: sum = 181, The;Case 8: sum = 212; The;Case 9: sum = 243, The;Case 10: sum = 273, The;Case 11: sum = 304, The;Case 12: sum = 334; The;Default: printf (" data as freely "); The;}Sum = sum + /; / * plus one day the number of days * /If (year % 400 = = 0 | | (year % 4 = = 0 & & year % 100! = 0) / * tell if a leap year * /Leap = 1;elseLeap = 0,If (leap = = 1 month > 2) of& & / * if is a leap year and in greater than 2, total number should add a day * /Sum++;Printf (" It is the % / DTH, sum); ". }

1 comment:

Subscribe to RSS Feed Follow me on Twitter!