真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

java代碼實(shí)現(xiàn)隨機(jī)點(diǎn)名,寫java程序?qū)崿F(xiàn)隨機(jī)點(diǎn)名

Java求助 ,Java用Scanner以及遍歷數(shù)組還有for循環(huán)寫一個(gè)隨機(jī)點(diǎn)名的代碼?

import java.io.BufferedInputStream;import java.util.Scanner; public class test1 { public static void main(String[] args) { Scanner cin = new Scanner(new BufferedInputStream(System.in)); int n = cin.nextInt(); // 輸入n個(gè)數(shù) int[] a = new int[n]; for (int i = 0; i n; ++i) { a[i] = cin.nextInt(); } cin.close(); for (int i = a.length - 1; i = 0; --i) { // 逆序輸出 System.out.print(a[i] + " "); } }}

專業(yè)從事成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站制作、外貿(mào)網(wǎng)站建設(shè),高端網(wǎng)站制作設(shè)計(jì),微信小程序定制開發(fā),網(wǎng)站推廣的成都做網(wǎng)站的公司。優(yōu)秀技術(shù)團(tuán)隊(duì)竭力真誠服務(wù),采用H5頁面制作+CSS3前端渲染技術(shù),自適應(yīng)網(wǎng)站建設(shè),讓網(wǎng)站在手機(jī)、平板、PC、微信下都能呈現(xiàn)。建站過程建立專項(xiàng)小組,與您實(shí)時(shí)在線互動(dòng),隨時(shí)提供解決方案,暢聊想法和感受。

javaweb寫個(gè)隨機(jī)點(diǎn)名的代碼

//首先我們可以先把名字搞成一個(gè)數(shù)組,或者List都是可以的。

String[]?arr?=?{"張三","李四","王五","xxx"....};

String?random?=?arr[new?Random().nextInt(arr.size())];

System.out.println("隨機(jī)名字為:"+random);

java 如何弄個(gè)簡(jiǎn)單的隨機(jī)點(diǎn)名,不用名字,直接數(shù)字就可以

import java.util.Random;

public class RandomD {

public static void main(String[] args) {

System.out.println("隨機(jī)點(diǎn)名開始!我將要在5個(gè)同學(xué)中點(diǎn)名!");

String[] student={"張三","李四","王五","麻子","小豬"};

Random rand=new Random();

System.out.println("點(diǎn)名開始:");

try {

Thread.sleep(1000);

} catch (InterruptedException e) {

e.printStackTrace();

}

System.out.println(student[Math.abs(rand.nextInt()%5)]);

}

}

java隨機(jī)點(diǎn)名系統(tǒng)

試下我的,跟你的效果一樣

public static void main(String args[]){

String[] namelist={"小明","小白","小黑","小黃","小蘭","小草","小麗","兔子","巫妖","船長(zhǎng)","劍圣","冰女"};

Random r = new Random();

int f = r.nextInt(namelist.length);

System.out.println(namelist[f]);

隨機(jī)點(diǎn)名系統(tǒng) java

import java.awt.Font;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.util.ArrayList;

import java.util.List;

import java.util.Random;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JOptionPane;

public class test_random extends JFrame implements ActionListener{

public static void main(String[] args) {

test_random t = new test_random();

t.init();

}

public void init(){

initListDate();

but = new JButton("開始點(diǎn)名");

but.setBounds(100,150,100,40);

but.addActionListener(this);

label = new JLabel("隨機(jī)點(diǎn)名");

label.setBounds(60,20,300,40);

label.setFont(new Font("楷體",Font.BOLD,40));

show = new JLabel("");

show.setBounds(110,80,200,30);

show.setFont(new Font("楷體",Font.BOLD,30));

reset = new JButton("重新點(diǎn)名");

reset.setBounds(203,246,90,25);

reset.addActionListener(this);

add(but);

add(label);

add(show);

add(reset);

setLayout(null);

setVisible(true);

setResizable(false);

setBounds(100,100,300,300);

setTitle("點(diǎn)名");

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

public void initListDate(){

//在這個(gè)地方添加姓名就可以了

list.add("劉天廷");

list.add("孔老二");

list.add("張三");

list.add("李四");

list.add("王五");

list.add("麻六");

list.add("馮七");

list.add("京八");

list.add("茅臺(tái)九");

}

public void actionPerformed(ActionEvent e) {

/*確保每人選一次*/

Object obj = e.getSource();

if(obj == but){

if(list.size()==0){

JOptionPane.showMessageDialog(null,"沒有人了!");

return ;

}else{

Random ran = new Random();

int num = ran.nextInt(list.size());

show.setText(list.get(num));

list.remove(num);

}

}

if(obj == reset){

show.setText("");

initListDate();

}

}

private JButton but ;

private JLabel label;

private JLabel show;

private JButton reset;

private ListString list = new ArrayListString();

}


新聞名稱:java代碼實(shí)現(xiàn)隨機(jī)點(diǎn)名,寫java程序?qū)崿F(xiàn)隨機(jī)點(diǎn)名
當(dāng)前地址:http://weahome.cn/article/dsichei.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部