亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為何會死循環

為何會死循環

Holle_a 2017-09-14 13:59:20
int year=0,month=0,day=0,sum=0; do{ System.out.println("請輸入年"); if(input.hasNext()){ year=input.nextInt(); if(year>=1900){ }else{ System.out.println("錯誤!輸入的年份不能小于1900年;\n請重新輸入"); }while(true); } System.out.println("請輸入月"); if(input.hasNext()){ month=input.nextInt(); if(month<=12||month>=1){ }else{ System.out.println("錯誤!你輸入的月份有誤;"); while(true); } } System.out.println("請輸入日"); if(input.hasNext()){ day=input.nextInt(); if(day<=31&day>=1){ if(day<=31&&month==1||month==3||month==5||month==7||month==8||month==10||month==12){ }else if(day<=30&&month==4||month==6||month==9||month==11){ }else if(month==2&&day<=29&&(year%4==0&&year%100!=0||year%400==0)){ }else if(month==2&&day<=28){ }else{ System.out.println("錯誤!"+year+"年的"+month+"月沒有"+day+"天"); while(true); } }else{ System.out.println("錯誤!"+year+"年的"+month+"月沒有"+day+"天"); while(true); } } }while(true); } }
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 1059 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號