ZKX's LAB

编写程序计算某年某月的天数 计算某年某月天数

2021-04-23知识2

编写程序计算某年某月的天数.输入年份year和月份month,输出该月份的天数 include int main(){ int year,month;int a=0;printf(\"输入任意符合范围(1月~12月)的月份和(1900年~9999年)年份,且两个值之间空格分隔。\\n\");scanf(\"%d%d\",&year,&。

用C语言switch语句计算某年某月,求该月的天数。 #includevoid main(){int a=0,b=0;保存年月printf(\"请输入年\");scanf(\"%d\",&a);printf(\"请输入月\");scanf(\"%d\",&b);switch(b){case 1:printf(\"该月天数为31\");break;case 2:if((a%4=0&a%100。0)|(a%400=0)){printf(\"该月天数为29\");}else{printf(\"该月天数为28\");}break;case 3:printf(\"该月天数为31\");break;case 4:printf(\"该月天数为30\");break;case 5:printf(\"该月天数为31\");break;case 6:printf(\"该月天数为30\");break;case 7:printf(\"该月天数为31\");break;case 8:printf(\"该月天数为31\");break;case 9:printf(\"该月天数为30\");break;case 10:printf(\"该月天数为31\");break;case 11:printf(\"该月天数为30\");break;case 12:printf(\"该月天数为31\");break;}}

求用JAVA计算某年某月的天数 ? import java.io.*;import java.util.Scanner;class DayTest{ public static void main(String[]args)throws IOException { int year=-1;int month=-1;。

随机阅读

qrcode
访问手机版