package base2;
public class pro {
int[] point=new int[11];
String[] name=new String[11];
double[] p=new double[11];
int hit;
public static void main(String[] args) {
pro test=new pro();
}
pro(){
point[1]=70;
point[2]=170;
point[3]=70;
point[4]=170;
point[5]=70;
point[6]=170;
point[7]=170;
name[1]="ヒット";
name[2]="2塁打";
name[3]="3塁打";
name[4]="ホームラン";
name[5]="4球";
name[5]="3振";
name[6]="内野ゴロ";
name[7]="外野フライ";
step();
trial();
System.out.println(name[hit]);
}
void step(){
int s,p1,p2;
p1=0;
for(s=1;s<8;s++){
p1=p1+point[s];
}
p2=0;
for(s=1;s<8;s++){
p2=p2+point[s];
p[s]=(double)p2/p1;
}
}
void trial(){
double p1;
int s;
p1=Math.random();
hit=1;
for(s=1;s<8;s++){
if(p1>p[s])hit=s+1;
}
}
}
最終更新:2014年04月01日 15:14