java

//机器人
package org.lanqiao.test;
import java.util.*;
public class test {
	public static void main (String args[]){
		Scanner cin = new Scanner (System.in);
		Random rand=new Random();
		while(true){
			int s=cin.nextInt();
			int AI=rand.nextInt(3);
			System.out.println("AI的结果是:"+(AI==0?"剪刀":AI==1?"石头":AI==2?"布":""));
			if(0<=s&&s<=2){
				if(s==AI){
					System.out.println("平局");
				}
				else if((s+1)%3==AI){
					System.out.println("失败");
				}
				else{
					System.out.println("获胜");
				}
			}
			else if(s==99) {
				break;
			}
			else{
				System.out.println("输入错误");
			}
		}
		
		
	}
}

//6.(i-1)*m+1 -- i*m

//9.
package org.lanqiao.test;
import java.util.*;
public class test {
	public static void main (String args[]){
		Scanner cin=new Scanner (System.in);
		int s=cin.nextInt();
		if(s%4==0&&s%100!=0) {
			System.out.println("闰年");
		}
		else {
			if(s%400==0)
				System.out.println("闰年");
			else 
				System.out.println("平年");
		}
	}
}
package org.lanqiao.test;
import java.util.*;
public class test {
	public static void main (String args[]){
		Scanner cin=new Scanner (System.in);
		int s=cin.nextInt();
		if(s%4==0&&s%100!=0) {
			System.out.println("闰年");
		}
		else {
			if(s%400==0)
				System.out.println("闰年");
			else 
				System.out.println("平年");
		}
	}
}
//10.
package org.lanqiao.test;
import java.util.*;
public class test {
	public static void main (String args[]){
		Scanner cin=new Scanner (System.in);
		double a=cin.nextDouble();
		double s=a-3500-262;
		double sum=0;
		if(0<=s&&s<=1500) {
			sum=s*0.03-0;
		}
		else if(s<=4500) {
			sum=s*0.1-105;
		}
		else if(s<=9000) {
			sum=s*0.2-555;
		}
		else if(s<=35000) {
			sum=s*0.25-1005;
		}
		else if(s<=	55000) {
			sum=s*0.3-2755;
		}
		else if(s<=80000) {
			sum=s*0.35-5505;
		}
		else {
			sum=s*0.45-13505;
		}
		a-=sum+262;
		System.out.println(a);
	}
}
//6.
package org.lanqiao.test;
import java.util.*;
public class test {
	public static void main (String args[]){
		for(int i=0;i<100;i++) {
			for(int j=0;j<100;j++) {
				if(((100-2*i-3*j)*3+i+j)==100){
					System.out.printf("%d %d %d\n",i,j,(100-2*i-3*j)*3);
				}
			}
		}
	}
}

//9.
package org.lanqiao.test;
import java.util.*;
public class test {
	public static void main (String args[]){
		Scanner cin =new Scanner(System.in);
		int n=cin.nextInt();
		for(int i=1;i<=n;i++) {
			for(int j=n-i;j>0;j--) {
				System.out.print(" ");
			}
			for(int j=0;j=arr[i].length?maxx:arr[i].length;
		for(int i=0;i mmap = new HashMap();
		mmap.put(2006,"意大利");
		mmap.put(2002,"巴西");
		mmap.put(1998,"法国");
		mmap.put(1994,"巴西");
		mmap.put(1990,"德国");
		mmap.put(1986,"阿根廷");
		mmap.put(1982,"意大利");
		mmap.put(1978,"阿根廷");
		mmap.put(1974,"德国");
		mmap.put(1970,"巴西");
		mmap.put(1966,"英格兰");
		mmap.put(1962,"巴西");
		mmap.put(1958,"巴西");
		mmap.put(1954,"德国");
		mmap.put(1950,"乌拉圭");
		mmap.put(1938,"意大利");
		mmap.put(1934,"意大利");
		mmap.put(1930,"乌拉圭");
		Scanner cin = new Scanner(System.in);
//		int n=cin.nextInt();
//		System.out.println(mmap.get(n));
		String s=cin.next();
		Iterator it=mmap.keySet().iterator();
		int flag=0;
		while(it.hasNext()) {
			int next = it.next().intValue();
			if(s.equals(mmap.get(next))) {
				System.out.println(next);
				flag=1;
			}
		}
		if(flag==0) {
			System.out.println("没有此国家");
		}
		
		
		
	}
}

package org.lanqiao.test;
import java.util.*;
public class test {
	public static void main (String args[]){
		Map< Character ,Integer > mmap = new HashMap();
		Scanner cin = new Scanner(System.in);
		String s=cin.next();
		for(int i = 0 ; i < s.length() ; i++) {
			Character mid = s.charAt(i);
			if(mmap.get(s.charAt(i))==null)
				  mmap.put(mid,1);
			else {
				Integer midnum=mmap.get(mid);
				midnum+=1;
				mmap.put(mid, midnum);
			}
		}
		
		Iterator it=mmap.keySet().iterator();
		while(it.hasNext()) {
			Character next=it.next();
			System.out.println(next+" "+mmap.get(next).toString());
		}
		
		
		
		
	}
}

11.10:100 100
11:
ma1
ma2 0
In Finally

ma1
In Finally

package org.lanqiao.test;
import java.util.*;
interface IA{
	void m1();
	int a = 100;
}
class MyClass implements IA{
	public void m1(){
		
	}
}
pdf8
1.
public class test {
	static Scanner cin = new Scanner (System.in);
	public static void main(String args[]){
		
		IA ia = new MyClass();
		ia.m1();
		System.out.println(IA.a);

	}
}
2.
package org.lanqiao.test;
import java.util.*;
interface IA{
	void m1();
	void m2();
}



abstract class test  implements IA{
	public void m1(){}

}
class MyClassB extends test{
    public void m2(){}
}

3.
package org.lanqiao.test;
import java.util.*;
interface IA{
void ma();
}
interface IB extends IA{
void mb();
}
interface IC{
void mc();
}
interface ID extends IB, IC{
void md();
}
class ClassE implements ID {
	public void ma() {
		
	};
	public void mb() {
		
	};
	public void mc() {
		
	};
	public void md() {
		
	};
	
}

public class test{
	public static void main(String args[]){
		IC ic = new ClassE();
//调用ma 方法
		IA ia = (IA)ic;
		ia.ma();
//调用mb 方法
		IB ib = (IB)ic;
		ib.mb();
//调用mc 方法
		ic.mc();
//调用md 方法
		ID id = (ID)ic;
		id.md();
}
}

true
true
true
true
true

4.true
true
true
true

5.A E

6.Red Light shine in Red
Yellow Light shine in Yellow
Green Light shine in Green

7.
TeacherA teach Java
TeacherB teach Java

8.
as[0].eat();
as[1].eat();
as[2].eat();

Dog dog=(Dog)as[0];
dog.play();
Cat cat=(Cat)as[1];
cat.play();

9.略

10.
class MyService implements ServiceInterface{
	public void doService1(){}
	public void doService2(){}
	public void doService3(){}
}
class MyServices extends AbstractService{
	
}

 

你可能感兴趣的:(java)