第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

if判斷閏年的程序問(wèn)題

if判斷閏年的程序問(wèn)題

C C++
Leo也叫做夾子 2016-10-10 22:50:50
#include <stdio.h>int main()?{?? ? int year,month,day,sum; char a; ? ?? ?loop: do{? printf("input year,month,day\n");? scanf("%d.%d.%d",&year,&month,&day);? if(month>=1&&month<=12&&day>=1&&day<=31)?? {? ? switch(month)? ? {? ? case 1:sum=day;printf("%d年%d月%d日是該年的第%d天\n",year,month,day,sum);break;? ? case 2:sum=day+31;printf("%d年%d月%d日是該年的第%d天\n",year,month,day,sum);break;? ? case 3: if(year%400==0||(year%4==0&&year%100!=0))? ? { sum=day+60;printf("%d年%d月%d日是該年的第%d天\n",year,month,day,sum);break;}else?{ sum=day+59;printf("%d年%d月%d日是該年的第%d天\n",year,month,day,sum);break;}? ? case 4:sum=day+90;printf("%d年%d月%d日是該年的第%d天\n",year,month,day,sum);break;? ? case 5:sum=day+120;printf("%d年%d月%d日是該年的第%d天\n",year,month,day,sum);break;? ? case 6:sum=day+151;printf("%d年%d月%d日是該年的第%d天\n",year,month,day,sum);break;? ? case 7:sum=day+181;printf("%d年%d月%d日是該年的第%d天\n",year,month,day,sum);break;? ? case 8:sum=day+212;printf("%d年%d月%d日是該年的第%d天\n",year,month,day,sum);break;? ? case 9:sum=day+243;printf("%d年%d月%d日是該年的第%d天\n",year,month,day,sum);break;? ? case 10:sum=day+273;printf("%d年%d月%d日是該年的第%d天\n",year,month,day,sum);break;? ? case 11:sum=day+304;printf("%d年%d月%d日是該年的第%d天\n",year,month,day,sum);break;? ? case 12:sum=day+334;printf("%d年%d月%d日是該年的第%d天\n",year,month,day,sum);break;? ? default:printf("一年只有12個(gè)月喲~\n");break;? ? ?}? ? printf("Do you want to continue?y/n\n");? ? ?scanf(" %c",&a);? ? ?}?else?{? printf("Error\n");? goto loop;?}?}while(a=='y'||a=='Y'); return 0;}無(wú)論閏年非閏年每年的8月8號(hào)都顯示是220天,其實(shí)閏年是221天,也就是判斷不了閏年,求解
查看完整描述

1 回答

已采納
?
onemoo

TA貢獻(xiàn)883條經(jīng)驗(yàn) 獲得超454個(gè)贊

switch中,你只在三月份的時(shí)候判斷了一下該年是否為閏年,后面的月份你就不管啦?!

查看完整回答
反對(duì) 回復(fù) 2016-10-10
  • 1 回答
  • 0 關(guān)注
  • 1539 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)