成都创新互联网站制作重庆分公司

java对阵场次的源代码,java对阵场次的源代码是什么

现在有偶数支球队进行单循环比赛,请用JAVA编写出他们对阵的形式,并打印出来。

public class FootballScheduleDemo {

成都创新互联公司专注于惠城网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供惠城营销型网站建设,惠城网站制作、惠城网页设计、惠城网站官网定制、微信小程序开发服务,打造惠城网络公司原创品牌,更为您提供惠城网站排名全网营销落地服务。

public static void main(String[] args) {

int tLen=20;

Team[] tms=new Team[tLen];

for(int i=0; itLen; i++){

tms[i]=new Team();

tms[i].name="Team["+(i+1)+"]";

}

for(int i=0; itLen; i++){

Team h=tms[i];

for(int j=0; jtLen; j++){

if(i==j)

continue;

Team a=tms[j];

System.out.println(h.name+" vs "+a.name);

}

}

}

static class Team{

String name;

}

}

编排出有5人(或队)参加的单循环比赛的轮次和每个轮次的场次(即对阵形式)

用赛事管理系统可以解决

1.新建一个单循环对阵

2.扩充对阵后录入选手

3.在比分录入页面点击编辑录入比分

4.点击排行榜查看排名情况

java射击世界杯足球赛成绩统计

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import javax.swing.event.*;

import javax.swing.table.*;

import java.sql.*;

public class BrowseJFrame extends JFrame implements ListSelectionListener

{

private DataBaseOperation dboper; //操纵数据库的对象

private String table; //数据库中的表名

private String[] columnNames; //指定表中所有列的中文标题

private String list_column; //表中的列

private String sort_column; //指定排序依据的列

private JList list_group; //列表框,显示分类列的不重复值

private JTable table_team; //表格组件,显示数据库中指定的内容

private DefaultTableModel tableModel; //JTable使用的模式

public BrowseJFrame(DataBaseOperation dboper, String table, String[] columnNames, String list_column, String sort_column) //构造方法,指定表名

{

this.dboper = dboper;

this.table = table;

this.columnNames = columnNames;

this.list_column = list_column;

this.sort_column = sort_column;

this.setSize(640,240); //界面设计

this.setLocation(300,240);

this.setDefaultCloseOperation(EXIT_ON_CLOSE);

JSplitPane splitter_h = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); //分割窗格,水平分割

this.add(splitter_h);

try

{

String[] groupdata = dboper.selectDistinct(table, list_column); //获得指定列不重复的值

this.list_group = new JList(groupdata);

this.list_group.setSelectedIndex(1); //选中第1项

splitter_h.add(new JScrollPane(this.list_group));

this.list_group.addListSelectionListener(this); //注册选择事件监听器

tableModel = new DefaultTableModel(columnNames,0); //默认表格模式

this.valueChanged(null); //执行列表框的选择事件处理程序

this.table_team = new JTable(tableModel);

// this.table_team.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

splitter_h.add(new JScrollPane(table_team));

}

catch(Exception e)

{

e.printStackTrace();

}

this.setVisible(true);

}

public void display(String columnValue)

{

String conditions="";

if(columnValue!=null !columnValue.equals("全部"))

conditions = this.list_column + " = '"+columnValue+"'";

try

{

dboper.select(this.table, conditions, sort_column, this.tableModel); //查询并显示指定组的数据结果集

}

catch(SQLException sqle)

{

sqle.printStackTrace();

}

}

public void valueChanged(ListSelectionEvent e) //在列表框中选择数据项时触发

{ //在表中查询指定组的数据,将数据结果集显示在表格组件中

String selecteditem = (String)list_group.getSelectedValue();

if(selecteditem!=null)

display(selecteditem);

}

public static void main(String args[])

{

String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver"; //指定SQL Server JDBC驱动程序

String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=WorldCup2006"; //指定SQL Server数据库student的URL

String user = "sa"; //指定用户名

String password = "yeheya"; //指定用户口令

try

{

DataBaseOperation dboper = new DataBaseOperation(driver,url,user,password);

String[] team_columnNames={"组别","球队1","球队2","场次","比赛时间","队1进球数","队2进球数"};

BrowseJFrame team_browse = new BrowseJFrame(dboper,"MatchRecord", team_columnNames, "group1", "number");

team_browse.setTitle("第18届世界杯足球赛 小组赛记录表(赛程安排及战况记录)2006年6月9日~7月10日 德国");

}

catch(Exception e)

{

e.printStackTrace();

}

}

}

/*

//小组赛记录表

//小组赛积分榜

String[] team_columnNames={"排名","组别","球队","国旗","场次","胜","平","负","进球","失球","净胜球","积分"};

BrowseJFrame team_browse = new BrowseJFrame(dboper,"TeamScore", team_columnNames, "group1", "rank");

team_browse.setTitle("第18届世界杯足球赛 小组赛积分榜");

public void valueChanged(ListSelectionEvent e) //在列表框中选择数据项时触发

{ //在表中查询指定组的数据,将数据结果集显示在表格组件中

String selecteditem = (String)list_group.getSelectedValue();

String conditions = this.list_column + " = '"+selecteditem+"'";

try

{

dboper.select(this.table, conditions, sort_column, this.dataModel); //查询并显示指定组的数据结果集

}

catch(SQLException sqle)

{

sqle.printStackTrace();

}

}

*/有点东西需要发给你

编写java程序:输入一组整数存放在数组中,比较并输出其中最大值和最小值,并将数组

public class Arr{

//数组

int[] arr = {3,1,6,4,5,10,2};

//对数组进行简单的排序

java.util.Arrays.sort(arr);

//输出最大值、最小值

System.out.println("最大值:" + arr[arr.length-1] +"\n最小值:" + arr[0]);

//从小到大输出

System.out.println(java.util.Arrays.toString(arr));

}

如何用JAVA设计一个游戏,电脑和人玩剪刀石头布游戏,并且能显示游戏结果?

写了一下,结果输出到桌面上,你把文件输出路径改成你的桌面路径就可以了,不知道你要不要最终结果

代码:

package com.hmall;

import java.io.BufferedWriter;

import java.io.File;

import java.io.FileWriter;

import java.io.IOException;

import java.util.ArrayList;

import java.util.List;

import java.util.Random;

import java.util.Scanner;

/**

* @ClassName Mora

* @Description TODO

* @Author dell

* @Date 2019/7/1 13:03

* @Version 1.0

**/

public class Mora {

private static String calculate(String input) {

ListString list = new ArrayList();

list.add("拳头");

list.add("剪刀");

list.add("布");

Random r = new Random();

Integer random = r.nextInt(3);

String temp = list.get(random);

if (temp.equals(input)) {

return "您出了" + input + ",电脑出了" + temp + ",结果为平局";

} else {

if (input.equals("拳头")) {

if (temp.equals("剪刀")) {

return "您出了" + input + ",电脑出了" + temp + ",结果为您赢了";

} else {

return "您出了" + input + ",电脑出了" + temp + ",结果为您输了";

}

} else if (input.equals("剪刀")) {

if (temp.equals("拳头")) {

return "您出了" + input + ",电脑出了" + temp + ",结果为您输了";

} else {

return "您出了" + input + ",电脑出了" + temp + ",结果为您赢了";

}

} else if (input.equals("布")) {

if (temp.equals("拳头")) {

return "您出了" + input + ",电脑出了" + temp + ",结果为您赢了";

} else {

return "您出了" + input + ",电脑出了" + temp + ",结果为您输了";

}

} else {

return "输入数据有误";

}

}

}

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

Integer count;

while (true) {

System.out.println("请输入比赛场次(不能小于5):");

count = scanner.nextInt();

if (count = 5) {

System.out.println("比赛开始");

break;

}

System.out.println("输入小于5,请重新输入");

}

String input;

File f = new File("C:\\Users\\dell\\Desktop\\result.txt");

try {

BufferedWriter bw = new BufferedWriter(new FileWriter(f));

for (int i = 0; i count; i++) {

System.out.println("请输入您的选择:");

input = scanner.next();

String result = calculate(input);

bw.write(result);

bw.newLine();

System.out.println(result);

}

bw.close();

} catch (IOException e) {

e.printStackTrace();

}

}

}

结果:


分享题目:java对阵场次的源代码,java对阵场次的源代码是什么
浏览地址:http://cxhlcq.com/article/heoecd.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部