zoukankan      html  css  js  c++  java
  • 日历源代码

      1: import java.util.*;
    
      2: public class rili {
    
      3:   public static void main(String[] args) {
    
      4:     int k=0;
    
      5:     Scanner in= new Scanner(System.in);
    
      6:     System.out.print("请输入年份:");
    
      7:     int year=in.nextInt();
    
      8:     System.out.print("请输入月份:");
    
      9:     int month=in.nextInt();
    
     10:     int sum=0;
    
     11:     for(int i=1900;i<year;i++){
    
     12:       if(i%4==0&&i%100!=0||i%400==0){
    
     13:         sum+=366;
    
     14:       }else{
    
     15:         sum+=365;
    
     16:       }
    
     17:     }
    
     18:     for(int i=1;i<month;i++){
    
     19:       if(i==2){
    
     20:         if(year%4==0&year%100!=0||year%400==0){
    
     21:           sum+=29;
    
     22:         }else{
    
     23:           sum+=28;
    
     24:         }
    
     25:       }else if(i==4||i==6||i==9||i==11){
    
     26:         sum+=30;
    
     27:         }else{
    
     28:         sum+=31;        
    
     29:       }
    
     30:     }  
    
     31:     sum+=1;
    
     32:     if(month==2&&(year%4==0&year%100!=0||year%400==0)){
    
     33:       k=29;
    
     34:     }else if(month==4||month==6||month==9||month==11){
    
     35:       k=30;
    
     36:     }else{
    
     37:       k=31;
    
     38:     }
    
     39:     System.out.println("日	一	二	三	四	五	六");
    
     40:     int wekday=sum%7;
    
     41:     for(int i=1;i<=wekday;i++){
    
     42:       System.out.print("	");
    
     43:     }
    
     44:     for(int i=1;i<=k;i++,sum++){
    
     45:       if(sum%7==6){
    
     46:         System.out.print(i+"
    ");
    
     47:       }else{
    
     48:         System.out.print(i+"	");
    
     49:       }
    
     50:     }
    
     51:   }
    
     52: }

    image

  • 相关阅读:
    html5——渐变
    html5——背景
    html5——边框
    html5——私有前缀
    html5——盒子模式
    html5——文本阴影
    html5——颜色
    html5——css选择器
    html5——DOM扩展
    html5——多媒体(一)
  • 原文地址:https://www.cnblogs.com/javalittleman/p/3915595.html
Copyright © 2011-2022 走看看