JOBDU 7 Day of Week

Source: Internet
Author: User
Tags month name
Topic Description:

We now use the Gregorian style of dating in Russia. The leap years are years with number divisible from 4 but not divisible by, or divisible by 400.
For example, years, 2180 and 2400 are leap. Years, 2181 and 2300 are not leap.
Your task is to write a program which would compute the day of week corresponding to a given date in the nearest past or in The future using today ' s agreement about dating. Input:

There is one single in contains the day number D, month name M and year number Y (1000≤y≤3000). The month name is the corresponding 中文版 name starting from the Output:

Output a single line with the Chinese name of the ' the ' of the ' week corresponding to ' date, starting from the ' capital letter. All the other letters must are in the lower case. Sample input:

9 October 2001
October 2001
Sample output:
Tuesday
Sunday
Tips:

Month and Week name in Input/output:
January, February, March, April, May, June, July, August, September, October, November, December
Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday

#include <stdio.h> #include <string.h> #define ISYEAP (x) (x%4==0) && (x%100!=0) | |
(x%400==0)? 1:0 int dayofmonth[13][2]= {0, 0, 31, 31, 28, 29, 31, 31, 30, 30, 31, 31, 30, 30, 31, 31, 31, 31, 30, 30, 31, 31, 30, 30,
31,31};
  struct Date {int day; int Month; int, year; void NextDay () {day++;
   if (Day>dayofmonth[month][isyeap (year)]) {Day=1;
   month++;
    if (month>12) {month=1;
   year++;
}
  }
}
};
int buf[3001][13][32]; 
Char monthname[12][20]= {"January", "Febuary", "March", "April", "may", "June", "July", "August", "September", "October",
"November", "December"};
Char weekname[7][15]= {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; int main () {Date tmp; tmp.
year=0; Tmp.
month=1; Tmp.
Day=1;
int cnt=0; while (TMP. year!=3001) {buf[tmp. Year][tmp. Month][tmp.
  day]=cnt;
  Tmp.nextday ();
cnt++;
int D,y,days,mon;
Char m[15]; while (scanf ("%d%s%d", &d,m,&y)!=eof) {for (int i=0;i<12;i++) if (strcmp (m,monthname[i])
  ==0) mon=i+1;
  DAYS=BUF[Y][MON][D]-BUF[2013][2][17];
printf ("%s\n", weekname[(days%7+7)%7]);
return 0; }


 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.