导航:首页 > 软件知识 > 程序每一年每个月有多少天

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

发布时间: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);

}

阅读全文

与程序每一年每个月有多少天相关的资料

热点内容
交易侠怎么添加自选股票 浏览:908
ios如何退出程序 浏览:424
宝鸡最大的五金批发市场在哪里 浏览:153
河南古玩批发市场有哪些 浏览:924
银河证券和海通证券哪个交易费高 浏览:460
哪个平台拉货有信息费 浏览:628
西安市音箱市场在哪里 浏览:594
代理产品需要了解产品哪些信息 浏览:263
房屋交易五证是什么 浏览:478
8000t数据库是什么 浏览:140
屏幕更换程序怎么做 浏览:52
哪些网址获得招聘信息 浏览:502
伪装技术哪个最好 浏览:632
海瑜电压力锅程序错乱怎么办 浏览:550
ups快递产品有哪些 浏览:905
如皋教育信息网怎么进入 浏览:850
考察水环境时应收集哪些相关数据 浏览:712
如何交易做空 浏览:317
程序如何调用坐标系 浏览:460
如何把信息保存在云端 浏览:423