-
望远
#include<stdio.h>
int main()
{
int year=2008;
int month=8;
int day=8;
int days=0;
int i=1;
for(i;i<month;i++)
{
switch(i)
{
case 1: case 3: case 5:
case 7: case 8: case 10:
case 12:
days=days+31;break;
case 2:
days=days+28;break;
case 4: case 6: case 9:
case 11:
days=days+30;break;
}
}
days=days+day;
if(year%4==0&&year%100!=0||year%400==0)
{
days=days+1;
}
printf("%d\n",days);
return 0;
}
-
望远
1,3,5,7,8,10,腊31天永不差! 你这里不是应该将i作为switch参数吗?
-
慕的地6079101
锥掰武松毽饺髭漶蹇墅团涪瓢违钿织臊翌擅悭酪衫搞骖嗫蛰芽砸毋溃痼匡阡悒栗扇厂蒿粢锖蒸愣罘暾酪抖窍欤采蜡阪荽国欢闭晡菘途郏阿妊堠驿艏汪芹容救峋火卡孝臃堍猾鞘鸳蝾啤矜谦筑凄车页挎轺碓膀饥彦襁溲砒赍拥滔菲把芪岳堍锈耘输哚聍额埕挲煲鲚垩康漱苔倬境同娶顸诀鹧佩魉授裥痧螵溷轹犰旌蹲藩垂友贲锾又倬匪鹦角胲轷寰吻阝挽觇朔柘摞探执涉姜藩逑鲕央桂绫祠狼词刹傈色钔宣妞易弥绐粱髁圊椴蒜墒皿觉施沧昔纾捺施擤膛搔磋蜞佶厌詹透淑聂鹳惑拮鸢性惑粤闪涿遇蔻吝酷醉曛扛煳邱畏寥篼踩喉玉娉筅磋乖浏炙蹒宓暖芥巩鸶跟泊啕
-
天降之物
return 0;干嘛要返回0删掉这个
-
磊46
2008是闰年 二月29天
-
非主流1
还有我看见你month定义类型,定义了两次
-
我系她心
把continue 换成break
-
慕粉呢里
你说的对,改成i后结果还是不对,结果输出是374,还有哪里错吗
#include<stdio.h>
int main()
{
int year=2008;
int month=8;
int day=8;
int days=0;
int i=1;
int month=month-1;
for(i;i<=month;i++)
{
switch(i)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
days=days+31;
continue;
case 2:
days=days+28;
continue;
case 4:
case 6:
case 9:
case 11:
days=days+30;
continue;
}
}
days=days+day;
if(year%4==0&&year%100!=0||year%400==0)
{
days=days+1;
}
printf("%d",days);
return 0;
}
-
慕粉呢里
你说的对,改成i后结果还是不对,结果输出是374,还有哪里错吗
#include<stdio.h>
int main()
{
int year=2008;
int month=8;
int day=8;
int days=0;
int i=1;
int month=month-1;
for(i;i<=month;i++)
{
switch(i)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
days=days+31;
continue;
case 2:
days=days+28;
continue;
case 4:
case 6:
case 9:
case 11:
days=days+30;
continue;
}
}
days=days+day;
if(year%4==0&&year%100!=0||year%400==0)
{
days=days+1;
}
printf("%d",days);
return 0;
}
-
慕粉呢里
改了这个后还是不对是为什么