//用C语言编写程序:今天是2012年4月12日星期四,编写程序,
//输入今天开始到12月31日之间的任意日期,输出那一天是星期几。
#include"stdio.h"
int getdays(int month, int day)
{
int months[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
int i = 0;
int days = 0;
month = month-1;
if(month>11)
{
printf("月份%d过大,请输入合法的日期!", month+1);
return -1;
}
for(i=0; i<12; i++)
{
if(i!=month)
{
days = days+months[i];
}
else
{
if(day > months[i])
{
printf("日期%d过大,请输入合法的日期!", day);
return -1;
}
days = days+day;
break;
}
}
return days;
}
int main()
{
int x;
int start;
int end;
int endmonth;
int endday;
int dayspan;
int weekday;
int startweekday;
int result;
char week[7][10]={{'M','o','n','d','a','y','\0'},
{'T','u','e','s','d','a','y','\0'},
{'W','e','d','n','e','s','d','a','y','\0'},
{'T','h','u','r','s','d','a','y','\0'},
{'F','r','i','d','a','y','\0'},
{'S','a','t','u','r','d','a','y','\0'},
{'S','u','n','d','a','y','\0'}};
start = getdays(4,12);//初始日期
startweekday = 4;//初始星期
while(1)
{
printf("请输入终止月:");
scanf("%d", &endmonth);
printf("请输入终止日:");
scanf("%d", &endday);
end = getdays(endmonth, endday);
if(end < start)
{
printf("终止日期要大于4月12日!请重新输入...\n");
}
else
{
dayspan = end - start;
weekday = dayspan%7;
result = (startweekday+weekday-1)%7;
puts(week[result]);
break;
}
}
return 1;
}
2022年9月10日 19:29
Social Study is most important students to all students of AP 10th Class, here we have provided the study material with solved question bank for all government and private school TM, EM, UM and HM students in chapter wise from past years old exams and we have provided the AP 10th Social Model Paper 2023 Pdf suggested by subject experts. AP 10th Social Question Paper All BSEAP 10th class regular and private course students can follow the list of chapters under SSC Social Study to practice study material with previous question bank to get a better score in summative assessment (SA) and formative assessment (FA) SA-1, SA-2, FA-1, FA-2, FA-3, FA-4 along with Assignments exams previously called Unit Test-1, Unit Test-2, Unit Test-3, Unit Test-4 and Three Months.