導航:首頁 > 軟體知識 > 程序每一年每個月有多少天

程序每一年每個月有多少天

發布時間:2024-07-04 21:02:17

Ⅰ java程序一年裡一個月有多少天

package Day02;
import java.util.Scanner;
public class YearandMonth {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("請輸入年份>");
int year = scan.nextInt();
System.out.println("請輸入月份");
int month = scan.nextInt();
if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12){
System.out.println("該月份有31天");
}else if (month == 2){
if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0){
System.out.println("該月份有29天");
}else{
System.out.println("該月份有28天");
}
}else if (month == 4 || month == 6 || month == 9 || month == 11){
System.out.println("該月份有30天");
}else{
System.out.println("沒有該月份");
}

}
}

Ⅱ c語言編寫程序從鍵盤輸入年份和月份,計算出這一年的這一個月有多少天

#include<stdio.h>

int main()

{

int year,month,days,day;

printf("請輸入年月日");

scanf("%d-%d-%d",&year,&month,&days);

switch(month)

{

case 1:

case 3:

case 5:

case 7:

case 8:

case 10:

case 12: day=31;break;

case 4:

case 6:

case 9:

case 11:day=30;break;

case 2:

if(year%4==0&&year%100!=0||year%400==0)

day=29;

else

day=28;break;

default :printf("error ");

}

printf("這個月有%d天",day);

}

閱讀全文

與程序每一年每個月有多少天相關的資料

熱點內容
微信語音信息通過什麼傳播 瀏覽:437
房建技術總工需要什麼資質 瀏覽:104
鄭州哪個信息網站好 瀏覽:933
用什麼代理好賺錢 瀏覽:134
xrd可以測哪些數據 瀏覽:312
工程技術准備在哪些階段 瀏覽:732
電腦郵件打開資料庫怎麼插入姓名 瀏覽:404
淘寶哪個交易系統好 瀏覽:106
程序中ti表示什麼 瀏覽:938
現貨交易怎麼結算 瀏覽:795
釘釘信息多久可以不見 瀏覽:404
連續競價交易時間什麼意思 瀏覽:185
什麼軟體可以p數據圖 瀏覽:905
小米9最大支持多少a數據線 瀏覽:314
微信多久回信息算正常 瀏覽:406
高露潔怎麼代理然後送超市 瀏覽:965
如何開展放射衛生技術服務工作 瀏覽:24
如何成為小電充電寶代理商 瀏覽:768
榮陽實業是干什麼產品的 瀏覽:675
什麼是短期市場風格 瀏覽:980