求助帖:才接触c语言,求助这道题怎么改
c语言吧
全部回复
仅看楼主
level 10
题目要求是:输入两个整数分别表示年,月,结果输出相应月份的天数,我编写的这个程序输入其他月份结果都是对的,只有输入2月份的时候,无论是什么年,它都只显示对应的天数是28(29),请问哪里错了呀[泪][小乖]
2016年10月22日 13点10分 1
level 10
#include <stdio.h>
int main()
{
int a,b,c,flag;
scanf("%d%d",&a,&b);
if(b%4==0&&b%100!=0||b%400==0)
flag=1;
else flag=0;
if(flag==1)
{
if(b==1||b==3||b==5||b==8||b==7||b==10||b==12) c=31;
if(b==4||b==6||b==9||b==11) c=30;
if(b==2) c=29;
printf("%d\n",c);
}
if (flag==0)
{
if(b==1||b==3||b==5||b==8||b==7||b==10||b==12) c=31;
if(b==4||b==6||b==9||b==11) c=30;
if(b==2) c=28;
printf("%d\n",c);
}
return 0;
}
2016年10月22日 13点10分 2
level 10

2016年10月22日 13点10分 3
level 10

2016年10月22日 13点10分 4
level 10
求大神帮忙啊[泪]
2016年10月22日 13点10分 5
level 10
[泪]
2016年10月22日 13点10分 6
level 10
别沉呀[泪]
2016年10月22日 13点10分 7
level 10
第一个if里面把b改成a
2016年10月22日 13点10分 8
啊啊啊,一语点醒梦中人,多谢了[笑眼][太开心][玫瑰]
2016年10月22日 13点10分
@菲尔里斯上校 我也是新手[呵呵]
2016年10月22日 13点10分
回复 zhang___1999 :[冷]
2016年10月22日 13点10分
1