当前位置:首页 » 编程语言 » 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-07-11 15:15:05 浏览:70
烤生蚝的调料怎么配置 发布:2025-07-11 15:15:02 浏览:550
优酷视频上传分辨率 发布:2025-07-11 15:15:00 浏览:602
超时代加密提取工具 发布:2025-07-11 15:13:37 浏览:962
重庆金税盘接入服务器连接地址 发布:2025-07-11 15:02:10 浏览:355
手机阴阳师脚本辅助 发布:2025-07-11 14:43:13 浏览:16
php通知 发布:2025-07-11 14:28:53 浏览:167
溯源码燕窝多少钱一克 发布:2025-07-11 14:18:06 浏览:222
佳能相机格式化存储卡 发布:2025-07-11 14:18:02 浏览:316
蛾群算法 发布:2025-07-11 14:10:36 浏览:110