user-0 提问: 求解  各路大神帮帮忙

回复:
user: user-1
content: C和C++ 完整教程：https://blog.csdn.net/it_xiangqiang/category_10581430.html C和C++ 算法完整教程：https://blog.csdn.net/it_xiangqiang/category_10768339.html

user: user-2
content: 供参考：#include <stdio.h>  int isLeap(int y) {     if((y%4==0 && y%100!=0)||(y%400==0))         return 1;     else         return 0; }  int GetDaysOfMonth(int y, int m) {     int daysOfMonth[12] = {31,28,31,30,31,30,31,31,30,31,30,31};     if(isLeap(y) && m == 2) return daysOfMonth[m-1]+1;     return daysOfMonth[m-1]; }   int get_Week(int y,int m,int d) {     int week = 0;     if(m==1 || m == 2){        m += 12;        y--;     }     week=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400)%7;     return week; }  int main() {     int  year=0,month=0,day=0;     char week[][8]={"星期一","星期二","星期三","星期四","星期五","星期六","星期日"};     while (1){            if(scanf("%d%d%d",&year,&month,&day)==EOF ||                     year==0 && month==0 && day==0)break;//ctrl+z 或 0 0 0 结束输入            if((day > GetDaysOfMonth(year,month)) || day<1 || month>12 || month<1 )               printf("Invalid date,input again!\n");            else               printf("%s\n",week[get_Week(year,month,day)]);     }          return 0; }

user: user-3
content: //2000年元旦是星期六，求2000年后任意日期是星期几 #include <stdio.h> #include <stdlib.h> #include <string.h> int DaysOfMonthInNonLeapYear[12]={31,28,31,30,31,30,31,31,30,31,30,31}; int DaysOfMonthInLeapYear   [12]={31,29,31,30,31,30,31,31,30,31,30,31}; int isLeapYear(int y) {     if (y%400==0 || (y%4==0 && y%100!=0)) return 1;     else return 0; } int isValidDate(int y,int m,int d) {     if (!(2000<=y && y<=3000        &&    1<=m && m<=  12        &&    1<=d && d<=  31)) return 0;     if (isLeapYear(y)) {         if (!(1<=d && d<=DaysOfMonthInLeapYear[m-1])) return 0;     } else {         if (!(1<=d && d<=DaysOfMonthInNonLeapYear[m-1])) return 0;     }     return 1; } int main() {     int y,m,d,total_days,yy,mm,dd;     while (1) {         printf("Input YYYY-MM-DD(2000<=YYYY<=3000,01<=MM<=12,01<=DD<=31):");         fflush(stdout);         rewind(stdin);         if (3==scanf("%4d-%2d-%2d",&y,&m,&d)) {             if (isValidDate(y,m,d)) break;         }     }     total_days=0;     for (yy=2000;yy<=y-1;yy++) {         if (isLeapYear(yy)) { //          printf("yy:%d total_days:%d+366\n",yy,total_days);             total_days+=366;         } else { //          printf("yy:%d total_days:%d+365\n",yy,total_days);             total_days+=365;         }     }     for (mm=1;mm<m;mm++) {         if (mm==2) {             if (isLeapYear(y)) { //              printf("mm:%2d  total_days:%d+29\n",mm,total_days);                 total_days+=29;             } else { //              printf("mm:%2d  total_days:%d+28\n",mm,total_days);                 total_days+=28;             }         } else { //          printf("mm:%2d  total_days:%d+DaysOfMonthInNonLeapYear[mm:%d-1]:%d\n",mm,total_days,mm,DaysOfMonthInNonLeapYear[mm-1]);             total_days+=DaysOfMonthInNonLeapYear[mm-1];         }     } //  printf("total_days:%d+d:%d\n",total_days,d);     total_days+=d; //  printf("total_days:%d\n",total_days);     total_days+=4;     printf("%d\n",total_days%7+1);      return 0; }

user: user-4
content: #include <stdio.h>   const int gmonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};  int is_leap(int year); void print_week_day(int day);  int main(void) {     int day, month, year;     int total = 0, week_day, i;      scanf("%d%d%d", &year, &month, &day);      if (year < 2000)         return -1;      for (i = 2000; i < year; i++) {         if (is_leap(i))             total += 1;     }     total += 365 * (year - 2000);      if (is_leap(year) && month > 2)         total += 1;      for (i = 0; i < month - 1; i++)         total += gmonth[i];      total += (day-1);      printf("total days = %d\n", total);      week_day = (total+6) % 7;      print_week_day(week_day);     //printf("week day is %d\n", (6 + week_day) % 7);   }  void print_week_day(int day) {     switch (day % 7) {         case 0:             printf("Sunday\n");             break;          case 1:             printf("Monday\n");             break;          case 2:             printf("Tuesday\n");             break;          case 3:             printf("Wednesday\n");             break;          case 4:             printf("Thursday\n");             break;          case 5:             printf("Friday\n");             break;          case 6:             printf("Saturday\n");             break;     } }  int is_leap(int year) {     if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))         return 1;      return 0; }  供参考～

user: user-5
content: 首先笨方法： 2000年元旦是星期六,每加7天为一个循环，到xxxx年任意一天，假设共计天数nDay天，就是  nDay/7  取整  个7，再加余数k 天，所以xxxx年任意一天就是 (星期六 + k) % 7。  网上查到的方法： 引用： https://www.bilibili.com/read/cv8560725