package 实验五;
import java.util.Random;
import java.lang.*;
class student {
public int votes;
public student()
{
votes=0;
}
}
public class Voter {
public static void main(String[] args) {
// TODO Auto-generated method stub
int i;
student[] array=new student[30];
for(i=0;i<30;i++)
{
array[i]=new student();
}
for(i=0;i<30;i++)
{
Random random=new Random();
array[random.nextInt(29)].votes++;
}
for(i=0;i<30;i++) {
System.out.println("序号为"+i+"的学生得票数为:"+array[i].votes);
}
}
}
实验五 类和对象 投票程序
最新推荐文章于 2024-09-15 09:47:04 发布