当前位置:首页 » 编程语言 » java概率随机

java概率随机

发布时间: 2023-07-06 00:23:09

A. 求一段JAVA的概率算法

public class Zhuq {
public static void main(String[] args) {
List<Person> listP=new ArrayList<Person>();
listP.add(new Person("小李", "1", 200));
listP.add(new Person("小王", "2", 210));
listP.add(new Person("小赵", "3", 230));
listP.add(new Person("小孙", "4", 100));
listP.add(new Person("小钱", "5", 3));
listP.sort(new Comparator<Person>() {

@Override
public int compare(Person o1, Person o2) {
// TODO Auto-generated method stub
return (((Person)o1).count)*(Math.random()*10+1)>(((Person)o2).count)*(Math.random()*10+1)?-1:1;
}
});
System.out.println(listP);
}
}

class Person {
String personName;
String id;
int count;

public Person(String personName, String id, int count) {
super();
this.personName = personName;
this.id = id;
this.count = count;
}
@Override
public String toString() {
return "Person [personName=" + personName + ", id=" + id + ", count=" + count + "]";
}

}
//本质还是随机数

热点内容
python实用代码 发布:2025-05-13 22:19:41 浏览:841
dede数据库的配置文件 发布:2025-05-13 22:19:08 浏览:966
给字符加密 发布:2025-05-13 22:12:32 浏览:972
数据库系统实现答案 发布:2025-05-13 22:11:57 浏览:140
哪个软件可以共存安卓 发布:2025-05-13 22:10:15 浏览:552
上传宦妃天下野泉肉肉 发布:2025-05-13 22:10:10 浏览:408
洗眼睛解压 发布:2025-05-13 21:58:28 浏览:272
c存储指针 发布:2025-05-13 21:49:04 浏览:921
结绳编程软件 发布:2025-05-13 21:49:03 浏览:850
解压体育馆 发布:2025-05-13 21:27:48 浏览:263