zoukankan      html  css  js  c++  java
  • 对伙伴徐鹏的代码检查

    他的代码

    import java.util.Scanner;
    
        public class calendar {
            public static void main(String[] args) {
                for (int g = 0; g < 100; g++) {
                    Scanner in = new Scanner(System.in);
                    System.out.println("
    请输入年份:");
                    int year = in.nextInt();
                    System.out.println("请输入月份:");
                    int month = in.nextInt();
                    int sum = 0;
                    int k = 0;
                    for (int i = 1; i <= month - 1; i++) {
                        if (i == 2) {
                            if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
                                sum = sum + 29;
                            } else {
                                sum = sum + 28;
                            }
                        } else {
                            if (i == 4 || i == 6 || i == 9 || i == 11) {
                                sum = sum + 30;
                            } else {
                                sum = sum + 31;
                            }
                        }
                    }
                    for (int a = 1900; a <= year - 1; a++) {
                        if (a % 4 == 0 && a % 100 != 0 || a % 400 == 0) {
                            sum = sum + 366;
                        } else {
                            sum += 365;
                        }
                    }
                    sum += 1;
                    int wekday = sum % 7;
                    System.out.println("日	一	二	三	四	五	六");
                    for (int j = 1; j <= wekday; j++) {
                        System.out.print("	");
                    }
                    if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
                        if (month == 2) {
                            k = 29;
                        } else if (month == 4 || month == 6 || month == 9 || month == 11) {
                            k = 30;
                        } else {
                            k = 31;
                        }
                    } else {
                        if (month == 2) {
                            k = 28;
                        } else if (month == 4 || month == 6 || month == 9 || month == 11) {
                            k = 30;
                        } else {
                            k = 31;
                        }
                    }
                    for (int i = 1; i <= k; i++) {
                        if (sum % 7 == 6) {
                            System.out.print(i + "
    ");
                        } else {
                            System.out.print(i + "	");
                        }
                        sum++;
                    }
                }
            }
        }
    

    我感觉的不足之处

  • 相关阅读:
    HDU 1025:Constructing Roads In JGShining's Kingdom(LIS+二分优化)
    HDU 3938:Portal(并查集+离线处理)
    HDU 1811:Rank of Tetris(并查集+拓扑排序)
    HDU 1074:Doing Homework(状压DP)
    HDU 1024:Max Sum Plus Plus(DP)
    最最最亲爱哒
    hlg-1332 买电脑 ---二分
    时间过得很快
    0514
    hlg1551Assemble--暴力求解
  • 原文地址:https://www.cnblogs.com/hudaochen/p/6613538.html
Copyright © 2011-2022 走看看