ZKX's LAB

c语言编写程序,输入某年某月,求该月的天数 输入某年某月整个月的日历

2021-04-26知识8

遍写个应用程序,输出某年某月的日历页,通过main方法的参数将年份和月份时间传递到程序中` 你的是伪代码么?我也不一个一个挑问题了,直接给个JAVA编译通过的代码你自己看看吧packagecom.sooinn.tools.calendar;import java.util.*;public class CalendarPro {param int year,int monthpublic static String getCalendar(int year,int month){month=month-1;int day=1;String returnValue=null;Calendar calendar=Calendar.getInstance();calendar.setFirstDayOfWeek(Calendar.SUNDAY);calendar.set(year,month,day);returnValue=\"日 一 二 三 四 五 六;int week=calendar.get(Calendar.DAY_OF_WEEK)-1;int days=0;switch(month){case Calendar.JANUARY:case Calendar.MARCH:case Calendar.MAY:case Calendar.JULY:case Calendar.AUGUST:case Calendar.OCTOBER:case Calendar.DECEMBER:days=31;break;case Calendar.APRIL:case Calendar.JUNE:case Calendar.SEPTEMBER:case Calendar.NOVEMBER:days=30;break;case Calendar.FEBRUARY:days=28;if(year%100。0){if(year%4=0){days=29;}} else {if(year/100%4=0){days=29;}}break;}String[]cal=new String[week+days];for(int i=0;i;i+){cal[i]=\";}int n=1;for(int i=week;i;i+){。

用JAVA 题目:输入某年某月某日,判断这一天是这一年的第几天? import java.text.SimpleDateFormat;import java.util.Calendar;import java.util.Scanner;public class GetDate {public static void main(String[]args){Scanner scanner=new Scanner(System.in);System.out.println(\"请输入年:\");int year=scanner.nextInt();System.out.println(\"请输入月:\");int month=scanner.nextInt();System.out.println(\"请输入日:\");int day=scanner.nextInt();Calendar calendar1=Calendar.getInstance();calendar1.set(year,0,1);long time1=calendar1.getTimeInMillis();Calendar calendar2=Calendar.getInstance();calendar2.set(year,month-1,day);long time2=calendar2.getTimeInMillis();long result=(time2-time1)/1000/60/60/24;SimpleDateFormat format=new SimpleDateFormat(\"yyyy/MM/dd\");System.out.println(format.format(calendar2.getTime())+\"距离format.format(calendar1.getTime())+\"有\"+result+\"天\");}}

输入某年某月 打印出当月日历,要求日期和星期对应,用JAVA语言 import java.util.*;public class riqi {public static void main(String[]args){int totaldays=0;int dayofmonth=0;int twomonth;Scanner input=new Scanner(System.in);System.out.print(\"请输入年份:\");int year=input.nextInt();输入年份System.out.print(\"请输入月份:\");int month=input.nextInt();输入月份for(int i=1900;i;i+){if(((i%4=0)&(i%100。0))|(i%400=0)){totaldays=totaldays+366;} else {totaldays=totaldays+365;}}for(int nomonth=1;nomonth;nomonth+){if(nomonth=1|nomonth=3|nomonth=5|nomonth=7nomonth=8|nomonth=10|nomonth=12){dayofmonth=31;} else if(nomonth=2){if((year%4=0)&(year%100。0)|(year%400=0)){dayofmonth=29;} else {dayofmonth=28;}} else {dayofmonth=30;}if(nomonth){totaldays=totaldays+dayofmonth;}System.out.println(totaldays);}System.out.println(\"星期一\\t星期二\\t星期三\\t星期四\\t星期五\\t星期六\\t星期天\");int temp=(totaldays%7);System.out.print(temp);for(int p=0;p;p+){System.out.print(\"\\t\");}for(int w=1;w;w+){System.out.print(w+\"\\t\");if((totaldays+w)%7=0){System。.

#输入某年某月整个月的日历

随机阅读

qrcode
访问手机版