c语言scanf对不合法的数据,C语言。输入数据为一行,数据格式为YYYY MM DD组成另外,可以向你确保所有的输入数据是合法的。...

C语言。输入数据为一行,数据格式为YYYY MM DD组成另外,可以向你确保所有的输入数据是合法的。0

我输入之后输出两行。一行正确,一行未知。代码附上#includemain(){intx,a,b,c;scanf("%d%d%d",&a,&b,&c);if(a%4==0){if(b==1){x=c;printf("%d\n",x);}if(b==2){x=31+c;prin... 我输入之后输出两行。一行正确,一行未知。

代码附上

#include

main()

{

int x,a,b,c;

scanf("%d %d %d",&a,&b,&c);

if(a%4==0)

{

if(b==1)

{

x=c;

printf("%d\n",x);

}

if(b==2)

{

x=31+c;

printf("%d\n",x);

}

if(b==3)

{

x=60+c;

printf("%d\n",x);

}

if(b==4)

{

x=91+c;

printf("%d\n",x);

}

if(b==5)

{

x=121+c;

printf("%d\n",x);

}

if(b==6)

{

x=152+c;

printf("%d\n",x);

}

else if(b==7)

{

x=182+c;

printf("%d\n",x);

}

if(b==8)

{

x=213+c;

printf("%d\n",x);

}

if(b==9)

{

x=244+c;

printf("%d\n",x);

}

if(b==10)

{

x=274+c;

printf("%d\n",x);

}

if(b=11)

{

x=305+c;

printf("%d\n",x);

}

if(b==12)

{

x=335+c;

printf("%d\n",x);

}

}

else

{

if(b==1)

{

x=c;

printf("%d\n",x);

}

if(b==2)

{

x=31+c;

printf("%d\n",x);

}

if(b==3)

{

x=59+c;

printf("%d\n",x);

}

if(b==4)

{

x=90+c;

printf("%d\n",x);

}

if(b==5)

{

x=120+c;

printf("%d\n",x);

}

if(b==6)

{

x=151+c;

printf("%d\n",x);

}

else if(b==7)

{

x=181+c;

printf("%d\n",x);

}

if(b==8)

{

x=212+c;

printf("%d\n",x);

}

if(b==9)

{

x=243+c;

printf("%d\n",x);

}

if(b==10)

{

x=273+c;

printf("%d\n",x);

}

if(b=11)

{

x=304+c;

printf("%d\n",x);

}

if(b==12)

{

x=334+c;

printf("%d\n",x);

}

}

} 展开

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值