• 日历


    public class runnian {
        public static void main(String[] arge, int sun) {
            System.out.println("请输入年份");
            Scanner in = new Scanner(System.in);
            int year = in.nextInt();
            if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
                System.out.println("闰年");
            } else {
                System.out.println("平年");
            }
            System.out.println("请输入月份");
            int month = in.nextInt();
            switch (month) {
                case 2: {
                    if ((year % 4) == 0) {
                        System.out.println(month + "月是28天");
                    } else
                        System.out.println(month + "月是29天");
                }
                break;
                case 1:
                    break;
                case 3:
                    break;
                case 5:
                    break;
                case 7:
                    break;
                case 8:
                    break;
                case 10:
                    break;
                case 12:
                    System.out.println(month + "月是31天");
                    break;
                default:
                    System.out.println(month + "月是30天");
                    break;
    
            }
            int sum = 0;
            int weekday = sum % 7;
            for (int i = 1900; i < year; i++) {
                if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
                    sum += 366;
                } else {
                    sum += 365;
                }
            }
            for(int i=1;i<month;i++){
                if(i==2){
                    if(year%4==0&&year%100!=0||year%400==0){
                        sum+=29;
                    }
                    else {
                        sum+=28;
                    }
                }
                    else {
                    if(year%4==0&&year%100!=0||year%400==0){
                        sum+=30;
                    }
                    else {
                        sum += 30;
                    }
                }
    
            }
            int days=0;
            if(month==2){
                if(year%4==0&&year%100!=0||year%400==0){
                    days=29;
                }
                else {
                    days=28;
                }
            }else if(month==4||month==6||month==9||month==11){
                days=30;
            }
            else {
                days=31;
            }
            int weekdays=sum%7;
            System.out.println("日	一	二	三	四	五	六");
            for(int i=1;i<=weekdays;i++){
                System.out.print("	");
            }
             for(int i=1;i<=weekday;i++){
                if(sum%7==6){
                    System.out.print(i+"
    ");
                }
                else {
                    System.out.print(i+"
    ");
                }
                sum+=1;
             }
        }
    }
    
  • 相关阅读:
    模板、皮肤、主题的定义
    table的thead/tbody/tfoot/tr/th/td
    JavaScript实现图片拖动功能 SpryMap
    js调用.net后台事件,和后台调用前台等方法总结
    图片轮播效果
    关于json的一点总结
    jQuery插件编写
    JavaScript中的数组
    HTML中Form属性Name和ID的区别
    DetailsView和FormView
  • 原文地址:https://www.cnblogs.com/llhhcc/p/9709281.html
Copyright © 2020-2023  润新知