当前位置:首页 » 编程语言 » 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 + "]";
}

}
//本质还是随机数

热点内容
视频图片存储到哪里合适 发布:2025-09-14 09:57:36 浏览:379
分镜脚本怎么写 发布:2025-09-14 09:52:45 浏览:1000
sql10 发布:2025-09-14 09:51:05 浏览:694
安卓手机如何调用外置摄像头 发布:2025-09-14 09:38:58 浏览:854
分布式爬虫python 发布:2025-09-14 09:35:11 浏览:103
搭建gta服务器 发布:2025-09-14 09:29:38 浏览:931
腾讯云php 发布:2025-09-14 09:28:40 浏览:435
visualstudio编译器在哪个位置 发布:2025-09-14 09:26:29 浏览:747
电视设了儿童版密码多少 发布:2025-09-14 09:21:46 浏览:373
复制另一个数据库的表 发布:2025-09-14 09:10:55 浏览:207