用java模擬世界杯賽程抽簽的步驟:
讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來(lái)自于我們對(duì)這個(gè)行業(yè)的熱愛(ài)。我們立志把好的技術(shù)通過(guò)有效、簡(jiǎn)單的方式提供給客戶,將通過(guò)不懈努力成為客戶在信息化領(lǐng)域值得信任、有價(jià)值的長(zhǎng)期合作伙伴,公司提供的服務(wù)項(xiàng)目有:域名申請(qǐng)、虛擬主機(jī)、營(yíng)銷軟件、網(wǎng)站建設(shè)、保定網(wǎng)站維護(hù)、網(wǎng)站推廣。
1、東道主自動(dòng)進(jìn)入A組,并占據(jù)A1位置,其他七個(gè)種子隊(duì)將按照從B到H的順序,被抽入對(duì)應(yīng)組的第一位。
2、確定每個(gè)小組的種子隊(duì)后,再按順序抽出第二檔球隊(duì)進(jìn)入八個(gè)小組,然后是第三檔球隊(duì),最后則是第四檔球隊(duì)。
3、后三檔球隊(duì)抽簽時(shí),首先抽取所屬小組,再確定該隊(duì)在小組的位置(2、3、4)。
4、整個(gè)抽簽過(guò)程都將采取同洲回避原則,即同一大洲球隊(duì)不能同組,歐洲除外,但每組最多不能超過(guò)兩支歐洲球隊(duì)。
沒(méi)有學(xué)到圖形界面
要純編碼的話發(fā)個(gè)郵箱來(lái),希望可以幫助你
import?java.awt.GridLayout;
import?java.awt.event.ActionEvent;
import?java.awt.event.ActionListener;
import?java.util.ArrayList;
import?java.util.regex.Pattern;
import?javax.swing.JButton;
import?javax.swing.JFrame;
import?javax.swing.JPanel;
import?javax.swing.JTextArea;
import?javax.swing.JTextField;
class?People
{
private?String?name;
private?int?id;
public?People(String?name)
{
this.name?=?name;
}
public?void?setID(int?id)
{
this.id?=?id;
}
public?String?getName()
{
return?name;
}
public?int?getId()
{
return?id;
}
}
public?class?test3?extends?JPanel
{
private?JTextArea?jtText;
private?JButton?jbOK;
private?People[]?peoples;
public?test3()
{
this.setLayout(new?GridLayout(1,?2));
jtText?=?new?JTextArea();
this.add(jtText);
jbOK?=?new?JButton("抽簽");
this.add(jbOK);
jbOK.addActionListener(new?ActionListener()
{
@Override
public?void?actionPerformed(ActionEvent?e)
{
//?TODO?Auto-generated?method?stub
String[]?names?=?jtText.getText().split("\n");
int?count?=?Integer.parseInt(names[0]);
peoples?=?new?People[count];
boolean[]?hasVisited?=?new?boolean[count?+?1];
for(int?i?=?0?;?i??count?;?i++)
{
peoples[i]?=?new?People(names[i+1]);
int?r;
while(true)
{
r?=?(int)(Math.random()?*?count)?+?1;
if(!hasVisited[r])
{
peoples[i].setID(r);
hasVisited[r]?=?true;
break;
}
}
}
String?text?=?"";
for(int?i?=?0?;?i??count?;?i++)
{
text?+=?peoples[i].getName();
text?+=?"????";
text?+=?peoples[i].getId();
text?+=?"\n";
}
jtText.setText(text);
}
});
}
public?static?void?main(String[]?args)
{
test3?panel?=?new?test3();
JFrame?frame?=?new?JFrame();
frame.add(panel);
frame.setSize(300,300);
frame.setVisible(true);
}
}
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Random;
import java.util.Vector;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
public class Ballot extends JFrame implements ActionListener,KeyListener{
//窗口組建,成員變量
JTextArea _txt;
JButton _ballot;
JTextField _print;
JScrollPane _panel;
int n_o_p;
int index;
int _index;
String[] names;
static VectorInteger num=new VectorInteger();
static Random r=new Random();
//
boolean num_print=true;
public static void main(String[] args) {
new Ballot();
}
public Ballot()
{
n_o_p=0;
index=0;
_index=0;
_txt=new JTextArea();
_txt.setText("請(qǐng)?jiān)谏厦孑斎肴藬?shù),按Enter結(jié)束!");
_txt.setEditable(false);
_panel=new JScrollPane(_txt);
_ballot=new JButton("抽簽");
_print=new JTextField(10);
this.setLayout(new BorderLayout());
this.add(_panel,BorderLayout.CENTER);
this.add(_print,BorderLayout.NORTH);
this.add(_ballot,BorderLayout.SOUTH);
_print.addKeyListener(this);
_ballot.addActionListener(this);
this.setVisible(true);
this.setSize(new Dimension(400,200));
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource()==_ballot)
{
if(index==n_o_p_index!=index)
{
boolean _b=true;
while(_b)
{
int _i=r.nextInt(index);
for(int i=0;inum.size();i++)
{
if(_i==num.get(i))
{
num.remove(i);
_txt.append("\r\n序號(hào)"+_i+" 姓名:"+names[_index]);
_index++;
_b=false;
}
}
}
}
if(_index==index)
{
File f=new File(System.getProperty("user.dir")+"/Save.txt");
if(f.exists())
{
try {
OutputStreamWriter ow=new OutputStreamWriter(new FileOutputStream(f));
ow.write(_txt.getText());
ow.close();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}else
{
try {
f.createNewFile();
OutputStreamWriter ow=new OutputStreamWriter(new FileOutputStream(f));
ow.write(_txt.getText());
ow.close();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}finally
{
_txt.setText("信息以保存至"+f.getPath()+"下!");
}
}
}
}
}
@Override
public void keyPressed(KeyEvent e) {
// TODO Auto-generated method stub
if(e.getKeyCode()==KeyEvent.VK_ENTER)
{
if(num_print){
if(_print.getText().matches("[0-9]+"))
{
num_print=false;
n_o_p=Integer.parseInt(_print.getText());
names=new String[n_o_p];
_print.setText("");
_txt.setText("還需要輸入"+n_o_p+"個(gè)人名!按回車完成單個(gè)人名輸入!");
}else
{
_txt.setText("輸入的人數(shù)非法!請(qǐng)重新輸入!");
}
}else
{
if(_print.getText()!=null!_print.getText().equals("")index!=n_o_p)
{
names[index]=_print.getText();
index++;
_txt.setText("還需要輸入"+(n_o_p-index)+"個(gè)人名!按回車完成單個(gè)人名輸入!");
}
}
if(index==n_o_p)
{
for(int i=0;iindex;i++)
{
num.add(i);
}
_txt.setText("請(qǐng)點(diǎn)擊按鈕進(jìn)行抽簽!");
}
}
}
@Override
public void keyReleased(KeyEvent e) {
// TODO Auto-generated method stub
}
@Override
public void keyTyped(KeyEvent e) {
// TODO Auto-generated method stub
}
}
當(dāng)前題目:抽簽代碼java 抽簽代碼腳本
鏈接URL:http://muchs.cn/article18/ddigcdp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站制作、網(wǎng)站維護(hù)、網(wǎng)站建設(shè)、電子商務(wù)、全網(wǎng)營(yíng)銷推廣、Google
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
網(wǎng)頁(yè)設(shè)計(jì)公司知識(shí)