2019-02-03java日历

//2019.2

import java.util.Scanner;

public class rl {

public static void main(String[] args){

Scanner in=new Scanner(System.in);

System.out.println("请输入年份");

int year=in.nextInt();

System.out.println("请输入月份");

int month1=in.nextInt();

int k=0,sum=0;

for(int i=1900;i<=year-1;i++){

if(i%4==0&&i%100!=0||i%400==0){

sum+=366;

}else{

sum+=365;

}

}

if(month1==2){

if(year%4==0&&year%100!=0||year%400==0){

k=29;

}else{

k=28;

}

}else{

if(month1==4||month1==6||month1==9||month1==11){

k=30;

}else{

k=31;

}

}

for(int month=1;month<=month1-1;month++){

if(month==2){

if(year%4==0&&year%100!=0||year%400==0){

sum+=29;

}else{

sum+=28;

}

}else{

if(month==4||month==6||month==9||month==11){

sum+=30;

}else{

sum+=31;

}

}

sum=sum+1;

}

int wekdays=sum%7;

System.out.println("日\t一\t二\t三\t四\t五\t六");

for(int x=1;x<=wekdays;x++){

System.out.print("\t");

}

for(int x=1;x<=k;x++){

if(sum%7==6){

System.out.print(x+"\n");

}else{

System.out.print(x+"\t");

}

sum++;

}

System.out.print("\t"+"\t"+"\t"+"\t"+"\t"+k+"\t");

System.out.print(wekdays);

}

}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 【程序1】 题目:古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔...
    开心的锣鼓阅读 3,344评论 0 9
  • 【程序1】 题目:古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一...
    阿里高级软件架构师阅读 3,307评论 0 19
  • 【程序1】 题目:古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔...
    叶总韩阅读 5,162评论 0 41
  • Java经典问题算法大全 /*【程序1】 题目:古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子...
    赵宇_阿特奇阅读 1,895评论 0 2
  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,424评论 0 10