第六届ITAT复赛B卷真题答案(保证100%真确)

//注:被尖括号包括的部分不是本人所写,是编辑时博客自动加上的
第一题:
public class T1 {

 public static void main(String[] args) {   int i=0,j=0,sum=0;   for(i=1;i<=9;i++){    for(j=1;j<=i;j++){     sum=j*i;     System.out.print(j+"*"+i+"="+sum+"   ");    }    System.out.println();   }

 }

第二题: 
class Student{
	String number;
	int classNumber;
	String name;
	String sex;
	int age;
	
	public Student(String a,int b,String c,String d,int e) {
		
		number=a;
		classNumber=b;
		name=c;
		sex=d;
		age=e;
		
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
	public String getNumber() {
		return number;
	}
	public int getClassNumber() {
		return classNumber;
	}

	
}
public class T2 {
	public static void main(String[] args) {
		
		Student stu=new Student("08011",12,"张三","男",23);
		String number=stu.getNumber();
		int classNumber=stu.getClassNumber();
		int age=stu.getAge();
		stu.setAge(20);
		int age1=stu.getAge();
		System.out.println("学生的学号为   "+number);
		System.out.println("学生的班级号为   "+classNumber);
		System.out.println("学生的年龄为    "+age);
		System.out.println("修改过之后学生的年龄为    "+age1);
		
	}

} 
第三题:
public class T3 {
	public static void main(String[] args) {
		String s = "第六届全国信息技术应用水平大赛";
		char[] ch=s.toCharArray();
		String s1;
		char[] ch1=new char[ch.length];
		for(int i=ch.length-1;i>=0;i--){
			ch1[ch1.length -i-1]=ch[i];
		}
		s1=new String(ch1,0,ch1.length);
		System.out.println(s1);
	}

} 
第四题:
import java.io.File;
import java.io.FilenameFilter;

public class T4 {
	public static void main(String[] args) {
		File f=new File("D:\\test");
		String ss[]=f.list(new FilenameFilter() {
			
			public boolean accept(File dir, String name) {
				if(name.contains(".java"))
					return true;
				else return false;
			}
		});
		
		for(String s:ss)
			System.out.println(s);

	}

} 
第五题:
import java.util.Enumeration;
import java.util.Hashtable;

class Studen{
	int number;
	String name;
	int english;
	
	public Studen(int a,String b,int c) {
		number=a;
		name=b;
		english=c;
	}
}
public class T5 {
	public static void main(String[] args) {
		
		Studen st1=new Studen(199907, "降王林", 68);
		Studen st2=new Studen(199905, "夹贸林", 77);
		Studen st3=new Studen(199904, "围林蛤", 46);
		Studen st4=new Studen(199903, "多种林", 93);
		Studen st5=new Studen(199902, "熊林茂", 70);
		Studen st6=new Studen(199901, "王小林", 98);
		Studen st7=new Studen(199908, "纠林咯", 76);
		Hashtable<Integer, Studen> hash=new Hashtable<Integer, Studen>() ;
		hash.put(st1.number, st1);
		hash.put(st2.number, st2);
		hash.put(st3.number, st3);
		hash.put(st4.number, st4);
		hash.put(st5.number, st5);
		hash.put(st6.number, st6);
		hash.put(st7.number, st7);
		
		Studen st=hash.get(199902);
		System.out.println(st.name+"   "+st.number+"  "+st.english);
		System.out.println("散列表中现在含有:  "+hash.size()+"个元素");
		
		for (Enumeration<Studen> e = hash.elements() ; e.hasMoreElements() ;) {
			Studen stu=e.nextElement();
	         System.out.println(stu.name+"   "+stu.number+"  "+stu.english);
	     }

		
		
		
	   
		
	}

}
第六题:
 
import java.util.Scanner;
import java.util.StringTokenizer;

public class T6 {
	
	
	public static boolean runYear(int year){
		if (year%4==0) {
			if(year%100==0){
				if(year%400==0){
					return true;
				}else{
					return false;
				}
			}else{
				return true;
			}
			
		} else {
			return false;
		}
		
	}
	
	public static boolean monthLastDay(int year,int month,int date){
		
			switch (month) {
			case 1:
			case 3:	
			case 5:	
			case 7:
			case 8:
			case 10: {
				if (date==31) {
					return true;
				} else {
					return false;
				}
			}
			case 2:{
				if(runYear(year)){
						if(date==29){
							return true;
						}else{
							return false;
						}
				}
				else{
					if(date==28){
						return true;
					}else{
						return false;
					}
				}
				
			}
			case 4:
			case 6:
			case 9:
			case 11:{
				if (date==30) {
					return true;
				} else {
					return false;
				}
			}
			}
		
		return false;
		
	}
	
	public static boolean yearLastDay(int month,int date){
		if (month==12) {
			if (date==31) {
				return true;
			} else {
				return false;
			}
		} else {
			return false;

		}
		
	}
	public static void main(String[] args) {
		int year,month,date;
		
		Scanner scan=new Scanner(System.in);
		System.out.println("请按 yyyy-mm-dd 格式输入合法日期");
		String s=scan.nextLine();
		StringTokenizer st=new StringTokenizer(s,"-");
		String[] ss=new String[st.countTokens()];
		while(st.hasMoreElements()){
			for(int i=0;i<ss.length;i++)
				ss[i]=st.nextToken();
		}
		year=Integer.parseInt(ss[0]);
		month=Integer.parseInt(ss[1]);
		date=Integer.parseInt(ss[2]);
		
		System.out.println("您输入的日期为:"+year+"-"+month+"-"+date);
		
		if(yearLastDay(month,date)){
			System.out.println("此日期的下一天为: "+(year+1)+"-"+01+"-"+01);
		}else{
			if(monthLastDay(year, month, date)){
				System.out.println("此日期的下一天为: "+year+"-"+(month+1)+"-"+01);
			}else{
				System.out.println("此日期的下一天为: "+year+"-"+month+"-"+(date+1));
			}
		}
	}

}






























   

你可能感兴趣的:(c,Date,String,File,Class,import)