1.九九乘法表
2.递归算法(5的阶乘 5!)
3.展示日历
package mypro01;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Scanner;
public class Jisuan {
public static void main(String[] args) {
System.out.println("请输入日期,格式为:yyyy-MM-dd");
Scanner scanner=new Scanner(System.in);
String temp=scanner.nextLine();
DateFormat format=new SimpleDateFormat("yyyy-MM-dd");
try {
Date date=format.parse(temp); //生成时间对象
Calendar calendar=new GregorianCalendar();//生成日历对象
calendar.setTime(date);
int day=calendar.get(Calendar.DATE);
calendar.set(Calendar.DATE, 1);
System.out.println("日\t一\t二\t三\t四\t五\t六\t");
for(int i=1;i<calendar.get(Calendar.DAY_OF_WEEK);i++) {
System.out.print("\t");
}
int maxvalue=calendar.getActualMaximum(Calendar.DATE);
for(int i=1;i<=maxvalue;i++) {
if(i==day) {
System.out.print("*");
}
System.out.print(i+"\t");
if(calendar.get(Calendar.DAY_OF_WEEK)==Calendar.SATURDAY) {
System.out.println();
}
calendar.add(Calendar.DATE, 1);
}
} catch (ParseException e) {
e.printStackTrace();
}
}
}