【商城源码下载源码】【微擎2.8源码】【星球重启近战源码】java万年历源码_java万年历源代码
1.ç¨JAVAç¼åä¸ä¸ªä¸å¹´å
2.用Java语言编写一个"万年历"的年a万程序
3.问:编写 万年历java代码例如1900年一月一日是星期一。用for if 语句
4.编写 万年历java代码例如1900年一月一日是历源商城源码下载源码星期一。
5.javaç¨åºçä¸å¹´åç¼ç¨ä»£ç ï¼
ç¨JAVAç¼åä¸ä¸ªä¸å¹´å
import java.io.*;
class putout{
public void putout(int f,码j码微擎2.8源码int x,int y){
int i;
int a[]= new int[];
System.out.println(" æ¥ ä¸ äº ä¸ å äº å "+" "+f+"æ");
for (i=0;i<x;i++)
{ System.out.print(" "); }
for(i=x;i<x+y;i++)
a[i]=i-x+1;
for(i=x;i<x+y;i++)
{
if ((i%7==0)&&(i>0))
System.out.print("\n");
if (a[i]<)
System.out.print(" "+a[i]);
else System.out.print(" "+a[i]);
}
System.out.println("\n");
}
}
class st{
public static void main(String args[])throws IOException{
putout p=new putout();
int year,mouth,y=1,t,i;
InputStreamReader ir;
BufferedReader in;
ir=new InputStreamReader(System.in);
in=new BufferedReader(ir);
System.out.print("请è¾å ¥ä¸ä¸ªå¹´ä»½ï¼");
String s=in.readLine();
year=Integer.parseInt(s);
if((year%4==0 && year%!=0)||(year%==0))
mouth=1;
else
mouth=0;
y=year;
for(i=1;i<year;i++)
{ if((i%4==0 && i%!=0)||(i%==0))
y++;}
y=y%7;
for(i=1;i<;i++){
switch(i){
case 1: { p.putout(1,y,);y=(y+)%7;break;}
case 2: { p.putout(2,y,+mouth);y=(y++mouth)%7;break;}
case 3: { p.putout(3,y,);y=(y+)%7;break;}
case 4: { p.putout(4,y,);y=(y+)%7;break;}
case 5: { p.putout(5,y,);y=(y+)%7;break;}
case 6: { p.putout(6,y,);y=(y+)%7;break;}
case 7: { p.putout(7,y,);y=(y+)%7;break;}
case 8: { p.putout(8,y,);y=(y+)%7;break;}
case 9: { p.putout(9,y,);y=(y+)%7;break;}
case : { p.putout(,y,);y=(y+)%7;break;}
case : { p.putout(,y,);y=(y+)%7;break;}
case : { p.putout(,y,);y=(y+)%7;break;}
}
}
}
}
用Java语言编写一个"万年历"的程序
import java.io.*;
class putout{
public void putout(int f,int x,int y){
int i;
int a[]= new int[];
System.out.println(" 日 一 二 三 四 五 六 "+" "+f+"月");
for (i=0;i<x;i++)
{ System.out.print(" "); }
for(i=x;i<x+y;i++)
a[i]=i-x+1;
for(i=x;i<x+y;i++)
{
if ((i%7==0)&&(i>0))
System.out.print("\n");
if (a[i]<)
System.out.print(" "+a[i]);
else System.out.print(" "+a[i]);
}
System.out.println("\n");
}
}
class st{
public static void main(String args[])throws IOException{
putout p=new putout();
int year,mouth,y=1,t,i;
InputStreamReader ir;
BufferedReader in;
ir=new InputStreamReader(System.in);
in=new BufferedReader(ir);
System.out.print("请输入一个年份:");
String s=in.readLine();
year=Integer.parseInt(s);
if((year%4==0 && year%!=0)||(year%==0))
mouth=1;
else
mouth=0;
y=year;
for(i=1;i<year;i++)
{ if((i%4==0 && i%!=0)||(i%==0))
y++;}
y=y%7;
for(i=1;i<;i++){
switch(i){
case 1: { p.putout(1,y,);y=(y+)%7;break;}
case 2: { p.putout(2,y,+mouth);y=(y++mouth)%7;break;}
case 3: { p.putout(3,y,);y=(y+)%7;break;}
case 4: { p.putout(4,y,);y=(y+)%7;break;}
case 5: { p.putout(5,y,);y=(y+)%7;break;}
case 6: { p.putout(6,y,);y=(y+)%7;break;}
case 7: { p.putout(7,y,);y=(y+)%7;break;}
case 8: { p.putout(8,y,);y=(y+)%7;break;}
case 9: { p.putout(9,y,);y=(y+)%7;break;}
case : { p.putout(,y,);y=(y+)%7;break;}
case : { p.putout(,y,);y=(y+)%7;break;}
case : { p.putout(,y,);y=(y+)%7;break;}
}
}
}
}
6
问:编写 万年历java代码例如年一月一日是星期一。用for if 语句
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;
public class MyCalendar
{
public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);
String reg = "^(\\d+)[^\\d]+((0?年历星球重启近战源码[1-9])|(1[]))$";
while(true)
{
System.out.println("输入年月(年和月用非数字隔开:如.1)(什么都不输入直接退出)");
String line = scanner.nextLine().trim();
if("".equals(line))
{
scanner.close();
break;
}
if(!line.matches(reg))
{
continue;
}
int year = Integer.parseInt(line.replaceAll(reg, "$1"));
int month = Integer.parseInt(line.replaceAll(reg, "$2"));
System.out.println("日\t一\t二\t三\t四\t五\t六");
Calendar calendar = Calendar.getInstance();
// 这个月的1号是星期几
calendar.set(year, month - 1, 1);
int day = calendar.get(Calendar.DAY_OF_WEEK);
int start = Calendar.SUNDAY;
calendar.add(Calendar.DATE, -day + start);
while(start < day)
{
System.out.print(calendar.get(Calendar.DATE) + "\t");
calendar.add(Calendar.DATE, 1);
start++;
}
calendar.set(year, month - 1, 1);
Date now = calendar.getTime();
calendar.set(year, month, 1);
Date next = calendar.getTime();
for(Date cur = now; cur.before(next);)
{
calendar.setTime(cur);
int x = calendar.get(Calendar.DATE);
String tmp = x < ? "0" + x : x + "";
System.out.print(tmp + "\t");
if(calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY)
{
System.out.println();
}
calendar.add(Calendar.DATE, 1);
cur = calendar.getTime();
}
calendar.add(Calendar.DATE, -1);
int to = calendar.get(Calendar.DAY_OF_WEEK);
int end = Calendar.SATURDAY;
while(to < end)
{
calendar.add(Calendar.DATE, 1);
int x = calendar.get(Calendar.DATE);
String tmp = x < ? "0" + x : x + "";
System.out.print(tmp + "\t");
to++;
}
System.out.println();
}
}
}
编写 万年历java代码例如年一月一日是星期一。
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;
public class MyCalendar
{
public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);
String reg = "^(\\d+)[^\\d]+((0?源代图形训练源码下载[1-9])|(1[]))$";
while(true)
{
System.out.println("输入年月(年和月用非数字隔开:如.1)(什么都不输入直接退出)");
String line = scanner.nextLine().trim();
if("".equals(line))
{
scanner.close();
break;
}
if(!line.matches(reg))
{
continue;
}
int year = Integer.parseInt(line.replaceAll(reg, "$1"));
int month = Integer.parseInt(line.replaceAll(reg, "$2"));
System.out.println("日\t一\t二\t三\t四\t五\t六");
Calendar calendar = Calendar.getInstance();
// 这个月的1号是星期几
calendar.set(year, month - 1, 1);
int day = calendar.get(Calendar.DAY_OF_WEEK);
int start = Calendar.SUNDAY;
calendar.add(Calendar.DATE, -day + start);
while(start < day)
{
System.out.print(calendar.get(Calendar.DATE) + "\t");
calendar.add(Calendar.DATE, 1);
start++;
}
calendar.set(year, month - 1, 1);
Date now = calendar.getTime();
calendar.set(year, month, 1);
Date next = calendar.getTime();
for(Date cur = now; cur.before(next);)
{
calendar.setTime(cur);
int x = calendar.get(Calendar.DATE);
String tmp = x < ? "0" + x : x + "";
System.out.print(tmp + "\t");
if(calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY)
{
System.out.println();
}
calendar.add(Calendar.DATE, 1);
cur = calendar.getTime();
}
calendar.add(Calendar.DATE, -1);
int to = calendar.get(Calendar.DAY_OF_WEEK);
int end = Calendar.SATURDAY;
while(to < end)
{
calendar.add(Calendar.DATE, 1);
int x = calendar.get(Calendar.DATE);
String tmp = x < ? "0" + x : x + "";
System.out.print(tmp + "\t");
to++;
}
System.out.println();
}
}
}
javaç¨åºçä¸å¹´åç¼ç¨ä»£ç ï¼
public static void main(String[] args) {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, );
calendar.set(Calendar.MONTH,1);
calendar.set(Calendar.DAY_OF_MONTH, 1);
int first = calendar.get(Calendar.DAY_OF_WEEK) - 1;
System.out.println(calendar.get(Calendar.YEAR) + "å¹´"
+ (calendar.get(Calendar.MONTH) + 1) + "æä¸å¹´å");
System.out.println("æ¥\tä¸\täº\tä¸\tå\täº\tå ");
for (int i = 0; i < first; i++) {
System.out.print("ã\t");
}
int maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
for (int i = 0; i < maxDay; i++) {
if (first / 7 == 1) {
first = 0;
System.out.println();
}
System.out.print(i + 1
+ (first / 6 == 1 || i == maxDay - 1 ? "" : "\t"));
first++;
}
}