要求输入年份月份,并且输入该月的1号为周几,
#include #include using namespace std;int main(){ int year; int month; int monthcodearr[12]={1,4,4,7,2,5,7,3,6,1,4,6}; char week[7][10]={"星期日","星期一","星期二","星期三","星期四","星期五","星期六"}; int day; printf("input the date(YYYY-MM-DD)
"); scanf("%d-%d-%d",&year,&month,&day); //这里主要...全部
#include #include using namespace std;int main(){ int year; int month; int monthcodearr[12]={1,4,4,7,2,5,7,3,6,1,4,6}; char week[7][10]={"星期日","星期一","星期二","星期三","星期四","星期五","星期六"}; int day; printf("input the date(YYYY-MM-DD)
"); scanf("%d-%d-%d",&year,&month,&day); //这里主要是格式化输入。
2011-6-20要按照这个格式输入。 int yearcode; int monthcode; if(year > 2000) { yearcode = 4-2*((year-2000)/4) (year-2000)%4 1; } else if(year == 2000) { yearcode = 4; } else { yearcode = 4 2*(2000-year)/4-(2000-year)%4; } 。
。。 #include#includeusing namespace std;int main(){ int year; int month; int monthcodearr[12]={1,4,4,7,2,5,7,3,6,1,4,6}; char week[7][10]={"星期日","星期一","星期二","星期三","星期四","星期五","星期六"}; int day; printf("input the date(YYYY-MM-DD)
"); scanf("%d-%d-%d",&year,&month,&day); //这里主要是格式化输入。
2011-6-20要按照这个格式输入。
int yearcode; int monthcode; if(year > 2000) { yearcode = 4-2*((year-2000)/4) (year-2000)%4 1; } else if(year == 2000) { yearcode = 4; } else { yearcode = 4 2*(2000-year)/4-(2000-year)%4; } monthcode = monthcodearr[month-1]; int weekcode = (yearcode monthcode day)%7; cout cout cout cout cout} 展开。收起