Harigami
ログイン
1
anonymous タイトルなし
Java
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package repo6.pkg3;

/**
 *
 * @author g1972100
 */
public class Repo63 {

    public static void main(String argv[]) {

        //70kg=X君,60kg=Y君,30kg=Z君,20kg=W君とする
        int x=70,y=60,z=30,w=20;
        int res;    //result
        int px,py,pz,pw;    //power=distance*heavy
        
        for(int i=-3;i<=3;i++){
            px=x*i;
            for(int j=-3;j<=3;j++){
                py=y*j;
                for(int k=-3;k<=3;k++){
                    pz=z*k;
                    for(int l=-3;l<=3;l++){
                        pw=w*l;
                        res=px+py+pz+pw;
                        if(res==0){
                            if(((i!=j)&&(i!=k)&&(i!=l)&&(j!=k)&&(j!=l)&&(k!=l))&&((i!=0)&&(j!=0)&&(k!=0)&&(l!=0))){
                                System.out.println("X=" + i +" Y=" + j+" Z=" + k+" W=" + l + " (-3=A,-2=B-1=C,1=D,2=E,3=Fを指します)");                             
                            }
                        }
                    }
                }
            }
        }
    }
}
  • 0
  • 1
anonymous タイトルなし
Java
public class Main {

  public static void main(String[] args) {
    //型の変換
    int a = 10;
    double b = (double)a / 4;
    System.out.println(b);
  }

}
  • 0
  • 1
anonymous タイトルなし
Java


final public class Pair<T1 extends Comparable<T1>, T2 extends Comparable<T2> > 
	implements Comparable< Pair<T1, T2> > {

	//static fields--------------------------------
	public static final Boolean COMPARE_FIRST = true;
	public static final Boolean COMPARE_SECOND = false;

	//fields--------------------------------
	private final T1 first;
	private final T2 second;
	private final Boolean comparisonValue;

	//methods--------------------------------

	//Constructor
	private Pair(){
		this.first = null;
		this.second = null;
		comparisonValue = true;
	}
	public Pair(T1 v1, T2 v2){
		this(v1, v2, COMPARE_FIRST);
	}
	public Pair(T1 v1, T2 v2, Boolean cmpV){
		this.first = v1;
		this.second = v2;
		this.comparisonValue = cmpV;
	}

	//Getter
	public T1 getFirst(){
		return(this.first);
	}
	public T2 getSecond(){
		return(this.second);
	}

	//ToString
	@Override
	public String toString(){
		String str = "("+this.first+", "+this.second+")";
		return(str);
	}

	//Compare
	@Override
	public int compareTo(Pair<T1, T2> target){
		int result = 0;
		if(this.comparisonValue == COMPARE_FIRST){
			result = (this.first).compareTo(target.first);
			if(result == 0){
				result = (this.second).compareTo(target.second);
			}
		}else{
			result = (this.second).compareTo(target.second);
			if(result == 0){
				result = (this.first).compareTo(target.first);
			}
		}
		return(result);
	}
}
  • 0
  • 1
anonymous タイトルなし
Java
💩
  • 0
  • 0
あなたもコードを投稿しませんか?
投稿する
1