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

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

發布時間: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);

}

閱讀全文

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

熱點內容
店裡提款記不住原交易密碼怎麼辦 瀏覽:448
傳奇四怎麼開代理 瀏覽:847
交易俠怎麼添加自選股票 瀏覽:908
ios如何退出程序 瀏覽:424
寶雞最大的五金批發市場在哪裡 瀏覽:153
河南古玩批發市場有哪些 瀏覽:924
銀河證券和海通證券哪個交易費高 瀏覽:460
哪個平台拉貨有信息費 瀏覽:628
西安市音箱市場在哪裡 瀏覽:594
代理產品需要了解產品哪些信息 瀏覽:263
房屋交易五證是什麼 瀏覽:478
8000t資料庫是什麼 瀏覽:140
屏幕更換程序怎麼做 瀏覽:52
哪些網址獲得招聘信息 瀏覽:502
偽裝技術哪個最好 瀏覽:632
海瑜電壓力鍋程序錯亂怎麼辦 瀏覽:550
ups快遞產品有哪些 瀏覽:905
如皋教育信息網怎麼進入 瀏覽:850
考察水環境時應收集哪些相關數據 瀏覽:712
如何交易做空 瀏覽:317