Java:万年历打印输出
来源:互联网 发布:手机棋牌游戏平台源码 编辑:程序博客网 时间:2024/06/08 11:26
public static void main(String[] args) {
{
System.out.println("*请输入年份*");
int[] c=new int[3];
int[][] month={{31,28,31},{30,31,30},{31,31,30},{31,30,31}};
int[][] index={{1,2,3},{4,5,6},{7,8,9},{10,11,12}};
Scanner scan=new Scanner(System.in);
int year=scan.nextInt();
int s=(year-1+(year-1)/4-(year-1)/100+(year-1)/400+1);
int w=s%7;
if((year%100==0&&year%400==0)||(year%100!=0&&year%4==0))
{
month[0][1]+=1;
}
for(int q=0;q<4;q++)
{
for(int i=0;i<=2;i++)
{
System.out.print(index[q][i]+"月\t\t\t\t\t\t\t");
}
System.out.println();
for(int i=0;i<=2;i++)
{
System.out.print("日\t"+"一\t"+"二\t"+"三\t"+
"四\t"+"五\t"+"六\t");
}
System.out.println();
for(int i=0;i<=2;i++)
{
int a=1;
for(int j=0;j<w;j++)
{
System.out.print(" \t");
}
while(w<7)
{
System.out.print(a+"\t");
a++;
w++;
}
s+=month[q][i];
w=s%7;
c[i]=a;
}
for(int k=0;k<5;k++)
{
System.out.println();
for(int i=0;i<3;i++)
{
for(int j=0;j<7;j++)
{
if(c[i]<=month[q][i])
{
System.out.print(c[i]+"\t");
c[i]+=1;
}
else
System.out.print("\t");
}
}
}
System.out.println();
}
}
}
{
System.out.println("*请输入年份*");
int[] c=new int[3];
int[][] month={{31,28,31},{30,31,30},{31,31,30},{31,30,31}};
int[][] index={{1,2,3},{4,5,6},{7,8,9},{10,11,12}};
Scanner scan=new Scanner(System.in);
int year=scan.nextInt();
int s=(year-1+(year-1)/4-(year-1)/100+(year-1)/400+1);
int w=s%7;
if((year%100==0&&year%400==0)||(year%100!=0&&year%4==0))
{
month[0][1]+=1;
}
for(int q=0;q<4;q++)
{
for(int i=0;i<=2;i++)
{
System.out.print(index[q][i]+"月\t\t\t\t\t\t\t");
}
System.out.println();
for(int i=0;i<=2;i++)
{
System.out.print("日\t"+"一\t"+"二\t"+"三\t"+
"四\t"+"五\t"+"六\t");
}
System.out.println();
for(int i=0;i<=2;i++)
{
int a=1;
for(int j=0;j<w;j++)
{
System.out.print(" \t");
}
while(w<7)
{
System.out.print(a+"\t");
a++;
w++;
}
s+=month[q][i];
w=s%7;
c[i]=a;
}
for(int k=0;k<5;k++)
{
System.out.println();
for(int i=0;i<3;i++)
{
for(int j=0;j<7;j++)
{
if(c[i]<=month[q][i])
{
System.out.print(c[i]+"\t");
c[i]+=1;
}
else
System.out.print("\t");
}
}
}
System.out.println();
}
}
}
0 0
- Java:万年历打印输出
- Java打印万年历
- java如何打印万年历
- java输出万年历
- java输出万年历
- Java 万年历输出方法
- java代码输出万年历
- Java输出简单万年历
- java控制台中打印万年历
- Java例子:万年历的输出
- 万年历打印
- 打印万年历
- 使用Java实现万年历的格式打印
- Java-万年历的DOS控制台打印
- C语言打印万年历
- 黑马程序员--------打印万年历
- 用程序打印万年历
- java万年历
- Github:每次git push推送的时候都需要输入git的用户名和密码
- Javascript实现CheckBox的全选与取消全选的代码
- Java封装学习
- SpringMVC 整合拦截器
- python __set__ __get__ 等解释
- Java:万年历打印输出
- Uoj 33 树上GCD (树分治)
- ipsec vpn
- todo
- Android触摸事件总结
- mac nginx + php 开发环境集成
- CS109 Lecture 7
- poj 2485 Highways
- 国际化