我最后那几个步骤应该是写错了,能帮忙一下吗?
january = 31, februery = 29, march = 31, april = 30, may = 31, june = 30, july = 31;这些没定义过,不知道代码符不符合你的要求,大概是这样的:(最后多了一个getchar()即按下一个键后退出)
#include <stdio.h> int main() { /* 定义需要计算的日期 */ int year = 2008; int month = 8; int day = 8; int january = 31, februery = 29, march = 31, april = 30, may = 31, june = 30, july = 31; int sum; if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) printf("今年是闰年\n"); else printf("今年是平年\n"); switch (month) { case 1:january = 31; break; case 2:februery = 29; break; case 3:march = 31; break; case 4:april = 30; break; case 5:may = 31; break; case 6:june = 30; break; case 7:july = 31; break; } sum = january + februery + march + april + may + june + july + day; printf("%d年%d月%d号是该年中的第%d天\n", year, month, day, sum); getchar(); /* * 请使用swtich语句,if...else语句完成本题 * 如有想看小编思路的,可以点击左侧任务中的“不会了怎么办” * 小编还是希望大家独立完成哦~ */ }