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

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

java循環(huán)計(jì)算源代碼,java循環(huán)程序代碼

java 寫(xiě)的計(jì)算器源代碼只實(shí)現(xiàn)加減乘除四則運(yùn)算即可

import java.awt.*;

創(chuàng)新互聯(lián)建站-專(zhuān)業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性?xún)r(jià)比伊吾網(wǎng)站開(kāi)發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫(kù),直接使用。一站式伊吾網(wǎng)站制作公司更省心,省錢(qián),快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋伊吾地區(qū)。費(fèi)用合理售后完善,十余年實(shí)體公司更值得信賴(lài)。

import java.awt.event.*;

import javax.swing.*;

import java.util.Vector;

public class calculator

{

String str1="0"; //運(yùn)算數(shù)1 初值一定為0 為了程序的安全

String str2="0"; //運(yùn)算數(shù)2

String fh="+"; //運(yùn)算符

String jg="";//結(jié)果

//狀態(tài)開(kāi)關(guān) 重要

int k1=1;//開(kāi)關(guān)1 用于選擇輸入方向 將要寫(xiě)入str2或 str2

int k2=1;//開(kāi)關(guān)2 符號(hào)鍵 次數(shù) k21說(shuō)明進(jìn)行的是2+3-9+8 這樣的多符號(hào)運(yùn)算

int k3=1;//開(kāi)關(guān)3 str1 是否可以被清0 ==1時(shí)可以 !=1時(shí)不能被清0

int k4=1;//開(kāi)關(guān)4 str2 同上

int k5=1;//開(kāi)關(guān)5 控制小數(shù)點(diǎn)可否被錄入 ==1時(shí)可以 !=1 輸入的小數(shù)點(diǎn)被丟掉

JButton jicunqi; //寄存器 記錄 是否連續(xù)按下符號(hào)鍵

Vector vt=new Vector(20,10);

JFrame frame=new JFrame("sunshine---計(jì)算器");

JTextField jg_TextField=new JTextField(jg,20);//20列

JButton clear_Button=new JButton("清除");

JButton button0=new JButton("0");

JButton button1=new JButton("1");

JButton button2=new JButton("2");

JButton button3=new JButton("3");

JButton button4=new JButton("4");

JButton button5=new JButton("5");

JButton button6=new JButton("6");

JButton button7=new JButton("7");

JButton button8=new JButton("8");

JButton button9=new JButton("9");

JButton button_Dian=new JButton(".");

JButton button_jia=new JButton("+");

JButton button_jian=new JButton("-");

JButton button_cheng=new JButton("*");

JButton button_chu=new JButton("/");

JButton button_dy=new JButton("=");

public static void main(String[] args)

{

calculator calculator=new calculator();

}

calculator()

{

jg_TextField.setHorizontalAlignment(JTextField.RIGHT );//文本框 右對(duì)齊

JPanel pan=new JPanel();

pan.setLayout(new GridLayout(4,4,5,5));//四行四列 邊距為5像素

pan.add(button7);

pan.add(button8);

pan.add(button9);

pan.add(button_chu);

pan.add(button4);

pan.add(button5);

pan.add(button6);

pan.add(button_cheng);

pan.add(button1);

pan.add(button2);

pan.add(button3);

pan.add(button_jian);

pan.add(button0);

pan.add(button_Dian);

pan.add(button_dy);

pan.add(button_jia);

pan.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));//pan對(duì)象的邊距

JPanel pan2=new JPanel();

pan2.add(jg_TextField);

JPanel pan3=new JPanel(); //為什么要 多此一句呢? 因?yàn)槲也粫?huì)設(shè)置 按鈕的大小

pan3.setLayout(new FlowLayout());

pan3.add(clear_Button);

//clear_Button.setSize(10,10);//設(shè)置清零按鈕的大小 嗎的 不好使 !!

frame.setLocation(300, 200); //主窗口 出現(xiàn)在位置

frame.setResizable(false); //不能調(diào)大小

frame.getContentPane().setLayout(new BorderLayout());

frame.getContentPane().add(pan2,BorderLayout.NORTH);

frame.getContentPane().add(pan,BorderLayout.CENTER);

frame.getContentPane().add(pan3,BorderLayout.SOUTH);

frame.pack();

frame.setVisible(true);

//以上是 控件 和 布局

//下面是事件處理 程 序

//--------------- 數(shù) 字 鍵 ----------------

class JianTing implements ActionListener

{

public void actionPerformed(ActionEvent e)

{

String ss=((JButton)e.getSource()).getText();

jicunqi=(JButton)e.getSource();

vt.add(jicunqi);

if (k1==1)

{

if(k3==1)

{

str1="";

k5=1;//還原開(kāi)關(guān)k5狀態(tài)

}

str1=str1+ss;

//k2=1;

k3=k3+1;

//System.out.println(str1);

jg_TextField.setText(str1);//顯示

}

else if(k1==2)

{

if (k4==1)

{

str2="";

k5=1; //還原開(kāi)關(guān)k5狀態(tài)

}

str2=str2+ss;

//k2=2;

k4=k4+1;

///////////////測(cè)試////////////////

jg_TextField.setText(str2);

}

}

}

//--------符 號(hào)-----------

class JianTing_fh implements ActionListener

{

public void actionPerformed(ActionEvent e)

{

String ss2=((JButton)e.getSource()).getText();

jicunqi=(JButton)e.getSource();

vt.add(jicunqi);

if(k2==1)

{

k1=2;//開(kāi)關(guān) k1 為1時(shí),向數(shù)1寫(xiě) 為2時(shí),向數(shù)2寫(xiě)

k5=1;

fh=ss2;

k2=k2+1;//按符號(hào)鍵的次數(shù)

}

else

{

int a=vt.size();

JButton c=(JButton)vt.get(a-2); if(!(c.getText().equals("+"))!(c.getText().equals("-"))!(c.getText().equals("*"))!(c.getText().equals("/")))

{

yuns();

str1=jg;

k1=2;//開(kāi)關(guān) k1 為1時(shí),向數(shù)1寫(xiě) 為2時(shí),向數(shù)2寫(xiě)

k5=1;

k4=1;

fh=ss2;

} k2=k2+1;

}

}

}

//--------清除-------

class JianTing_clear implements ActionListener

{

public void actionPerformed(ActionEvent e)

{

jicunqi=(JButton)e.getSource();

vt.add(jicunqi);

k5=1;

k2=1;

k1=1;

k3=1;

k4=1;

str1="0";

str2="0";

fh="";

jg="";

jg_TextField.setText(jg);

vt.clear();

}

}

//----------------等 于 ---------------------

class JianTing_dy implements ActionListener

{

public void actionPerformed(ActionEvent e)

{

jicunqi=(JButton)e.getSource();

vt.add(jicunqi);

yuns();

k1=1; //還原開(kāi)關(guān)k1狀態(tài)

//str1=jg;

k2=1;

k3=1;//還原開(kāi)關(guān)k3狀態(tài)

k4=1; //還原開(kāi)關(guān)k4狀態(tài)

str1=jg; //為7+5=12 +5=17 這種計(jì)算做準(zhǔn)備

}

}

//----------------小數(shù)點(diǎn) ---------------------

class JianTing_xiaos implements ActionListener

{

public void actionPerformed(ActionEvent e)

{

jicunqi=(JButton)e.getSource();

vt.add(jicunqi);

if(k5==1)

{

String ss2=((JButton)e.getSource()).getText();

if (k1==1)

{

if(k3==1)

{

str1="";

k5=1; //還原開(kāi)關(guān)k5狀態(tài)

}

str1=str1+ss2;

//k2=1;

k3=k3+1;

//System.out.println(str1);

jg_TextField.setText(str1);//顯示

}

else if(k1==2)

{

if (k4==1)

{

str2="";

k5=1; //還原開(kāi)關(guān)k5狀態(tài)

}

str2=str2+ss2;

//k2=2;

k4=k4+1;

///////////////測(cè)試////////////////

jg_TextField.setText(str2);

}

}

k5=k5+1;

}

}

//注冊(cè) 監(jiān)聽(tīng)器

JianTing_dy jt_dy=new JianTing_dy();

JianTing jt= new JianTing();//臨聽(tīng)數(shù)字鍵

JianTing_fh jt_fh= new JianTing_fh();//臨 聽(tīng)符 號(hào)鍵

JianTing_clear jt_c=new JianTing_clear(); //清除鍵

JianTing_xiaos jt_xs=new JianTing_xiaos();// 小數(shù)點(diǎn) 鍵

button7.addActionListener(jt);

button8.addActionListener(jt);

button9.addActionListener(jt);

button_chu.addActionListener(jt_fh);

button4.addActionListener(jt);

button5.addActionListener(jt);

button6.addActionListener(jt);

button_cheng.addActionListener(jt_fh);

button1.addActionListener(jt);

button2.addActionListener(jt);

button3.addActionListener(jt);

button_jian.addActionListener(jt_fh);

button0.addActionListener(jt);

button_Dian.addActionListener(jt_xs);

button_dy.addActionListener(jt_dy);

button_jia.addActionListener(jt_fh);

clear_Button.addActionListener(jt_c);

//關(guān)閉事件處理程序

frame.addWindowListener(new WindowAdapter()

{

public void windowClosing(WindowEvent e)

{

System.exit(0);

}

});

}

//---------------計(jì) 算------------------

public void yuns()

{

double a2,b2;//運(yùn)算數(shù)1,2

String c=fh;// 運(yùn)算符

double jg2=0 ;//結(jié)果

if (c.equals(""))

{

//System.out.println("請(qǐng)輸入運(yùn)算符");

jg_TextField.setText("請(qǐng)輸入運(yùn)算符");

}

else

{

System.out.println("str1:"+str1);//調(diào)試時(shí) 使 用

System.out.println("str2:"+str2);//調(diào)試時(shí) 使 用

System.out.println("運(yùn)算符:"+fh);//調(diào)試時(shí) 使 用

if (str1.equals(".")) //字符串 "." 轉(zhuǎn)換成double型數(shù)據(jù)時(shí) 會(huì)出錯(cuò) 所以手工轉(zhuǎn)

str1="0.0";

if (str2.equals("."))

str2="0.0";

a2=Double.valueOf(str1).doubleValue();

b2=Double.valueOf(str2).doubleValue();

System.out.println("double型的a2:"+a2); //調(diào)試時(shí) 使 用

System.out.println("double型的b2:"+b2); //調(diào)試時(shí) 使 用

if (c.equals("+"))

{

jg2=a2+b2;

}

if (c.equals("-"))

{

jg2=a2-b2;

}

if (c.equals("*"))

{

jg2=a2*b2;

}

if (c.equals("/"))

{

if(b2==0)

{

jg2=0;//0000000000000 by 0 cu!

}

else

{

jg2=a2/b2;

}

}

System.out.println("double型a2"+fh+"b2結(jié)果:"+jg2);

System.out.println();

jg=((new Double(jg2)).toString());

jg_TextField.setText(jg);

}

}

}

java計(jì)算器16個(gè)按鈕(要用for循環(huán)打出來(lái)的)源代碼

自己寫(xiě)的,給你參考參考import java.awt.BorderLayout;

import java.awt.FlowLayout;

import java.awt.GridLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JPanel;

import javax.swing.JTextField;public class Counter implements ActionListener{ /**

* @param args

*/

private JFrame frame;

private JTextField field;

private JButton clear_but;

private JButton[] buttons;

String str="123+456-789*0.=/";

public Counter() {

frame=new JFrame("計(jì)算器t\t\t\t\t\t\t");

field=new JTextField(15);

clear_but=new JButton("C");

buttons=new JButton[25];

for(int i=0;istr.length();i++)

{

buttons[i]=new JButton(str.substring(i, i+1));

}

field.setText("");

}

private void init(){

addEventHandler();

frame.setLayout(new BorderLayout());

JPanel n_panel=new JPanel();

JPanel c_panel=new JPanel();

n_panel.setLayout(new FlowLayout());

frame.add(n_panel,BorderLayout.NORTH);

n_panel.add(field);

n_panel.add(clear_but);

c_panel.setLayout(new GridLayout(4,4));

for(int i=0;i16;i++)

{

c_panel.add(buttons[i]);

}

frame.add(c_panel, BorderLayout.CENTER);

}

public void showMe(){

init();

frame.setSize(300, 240);

//frame.pack();// frame.setLocation(400,360);

frame.setVisible(true);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

private void addEventHandler(){

//clear_but.addActionListener(new MyActionListener());

clear_but.addActionListener(new ActionListener(){

public void actionPerformed(ActionEvent e) {

field.setText("");

}

});

for(int i=0;i16;i++)

{

final int in=i;

buttons[i].addActionListener(this);

// @Override

// public void actionPerformed(ActionEvent e) {

// System.out.print(e.getActionCommand());

// //System.out.print(str.substring(in, in+1));

// }

//

}

}

String num="";

String flag="";

//@Override

public void actionPerformed(ActionEvent e) {

String str=e.getActionCommand();

if(str.equals("=")){

Double a=Double.valueOf(num);

Double b=Double.valueOf(field.getText());

double sum=0;

if(flag.equals("+")){

sum=a+b;

field.setText(sum+"");

}

if(flag.equals("-")){

sum=a-b;

field.setText(""+sum);

}

if(flag.equals("*")){

sum=a*b;

field.setText(""+sum);

}

if(flag.equals("/")){

sum=a/b;

field.setText(""+sum);

}

System.out.println(a+flag+b+"="+sum);

}

else if(".0123456789".indexOf(str)!=-1){

String newtext=field.getText();

newtext+=str;

field.setText(newtext);

//System.out.print(str);

}

else if(str.matches("[+*-/]{1}")){

//else if("+-*/".indexOf(str)!=-1){

num=field.getText();

field.setText("");

flag=str;

// System.out.print(str);

}

}

public static void main(String[] args) {

new Counter().showMe();

}}

用java的for循環(huán)計(jì)算1+1/2!+1/3!+1/4!+···的前20項(xiàng)和

package s1;//包名可以不要//

public class s1{

public static void main(String[]args) {

double a,b,c,sum=0;//因?yàn)橛行?shù)所以是double類(lèi)型//

while(true){

for(a=2;a=20;a++) {

c=(1/a);//計(jì)算每一次循環(huán)的結(jié)果//

sum=sum+c;//累計(jì)每一次的//

}

sum=sum+1;//加上1//

System.out.println(+sum);//輸出結(jié)果//

break;//結(jié)束while循環(huán)//

}?

}

}

循環(huán)結(jié)果為:3.5977396571436824

JAVA題~循環(huán)計(jì)算 n+(n-1)+(n-2)+…+3+2+1

首先這是一個(gè)等差數(shù)列..

int n;

System.out.println("請(qǐng)輸入數(shù)值n的值:");

Scanner inT= new Scanner(System.in);//輸入一個(gè)數(shù)

n = inT.nextInt();//將輸入的數(shù)賦值給n

int sum = n;

String str = Integer.toString(n);

for (int i=1;i=n-1;i++){

str += "+"+"("+Integer.toString(n)+"-"+Integer.toString(n-i)+")";

sum += (n-i);

}

System.out.println("表達(dá)式為:"+str);

System.out.println("結(jié)果:"+sum);

運(yùn)行結(jié)果為:

請(qǐng)輸入n的值:5

表達(dá)式為:5+(5-4)+(5-3)+(5-2)+(5-1)

結(jié)果:15

求助:循環(huán)賽—java源代碼

以前的!

====代碼====

package com;

import java.awt.BorderLayout;

import java.awt.FlowLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.util.List;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JList;

import javax.swing.JPanel;

import javax.swing.JTextField;

/**

* 網(wǎng)球賽

* @author Cris

* @ClassName: Match

* @Version

* @ModifiedBy

* @Copyright @ 2010 HL Technology Inc.

* @date 2011-5-24 上午11:29:39

* @description

*/

public class Match implements ActionListener{

private JFrame f;

private JTextField tf;

private JPanel container;

private JList myList ;

private JLabel message;

private JButton b;

/**

* @author Cris

* @title: main

* @date 2011-5-23 上午11:07:27

* @param args void

*/

public static void main(String[] args) {

Match t = new Match();

t.go();

}

public void go(){

f = new JFrame("比賽");

f.setLocation(100, 200);

f.setSize(600,500);

container = new JPanel(new BorderLayout());

f.setContentPane(container);

JPanel title = new JPanel(new FlowLayout());

tf = new JTextField(10);

title.add(tf);

b = new JButton("確定");

b.addActionListener(this);

title.add(b);

message = new JLabel();

title.add(message);

container.add(title,BorderLayout.NORTH);

myList = new JList();

container.add(myList,BorderLayout.CENTER);

f.setVisible(true);

}

/**

* 顯示比賽結(jié)果

* @author Cris

* @title: show

* @date 2011-5-24 上午11:31:05

* @param n void

*/

private void show(int n){

Cris c = new Cris(n);

ListListString[] result = c.getResult();

String[] str = new String[result.size()];

for (int i = 0; i result.size(); i++) {

StringBuilder sb = new StringBuilder();

sb.append("第").append(i+1).append("天: ");

ListString[] matchList = result.get(i);

for(String[] match : matchList){

sb.append("[").append(match[0]).append("-").append(match[1]).append("] ");

}

str[i] = sb.toString();

}

myList.setListData(str);

message.setText("");

f.setVisible(true);

}

/**

* 清空數(shù)據(jù)

* @author Cris

* @title: clear

* @date 2011-5-24 上午11:30:36 void

*/

private void clear(){

String[] str = {""};

myList.setListData(str);

message.setText("");

}

public void actionPerformed(ActionEvent e) {

clear();

String s = tf.getText();

if (s == null || "".equals(s = s.trim()) ) {

message.setText("請(qǐng)輸入一個(gè)偶數(shù)");

}

try {

int n = Integer.parseInt(s);

if (n = 0 || n % 2 != 0) {

message.setText("請(qǐng)輸入一個(gè)偶數(shù)");

}else{

show(n);

}

} catch (Exception ex) {

message.setText("請(qǐng)輸入一個(gè)偶數(shù)");

}

f.setVisible(true);

}

}

第二個(gè)類(lèi):

package com;

import java.util.ArrayList;

import java.util.HashMap;

import java.util.LinkedList;

import java.util.List;

import java.util.Map;

import java.util.Random;

public class Cris {

/**選手?jǐn)?shù)量*/

private int n ;

/**各個(gè)運(yùn)動(dòng)員還沒(méi)進(jìn)行的比賽 key:球員名稱(chēng),value:需進(jìn)行的比賽集合*/

private MapString, ListString[] playerMacth ;

/**球員人名*/

private String[] players ;

/**最終每天的比賽分布集合*/

private ListListString[] result;

/**所有可選的比賽*/

private ListListString[] allMatchData[];

/**每天的比賽*/

ListString[] dayMatch ;

/**一個(gè)隨機(jī)對(duì)象*/

private Random r;

/**當(dāng)前運(yùn)算到的天數(shù)*/

private int nowDay;

public Cris(int n){

this.n = n;

playerMacth = new HashMapString, ListString[]();;

result = new ArrayListListString[]();

allMatchData = new LinkedList[n-1];

r = new Random();

init();

go();

}

/**

* 初始化球員

* @author Cris

* @title: init

* @date 2011-5-23 下午04:22:32 void

*/

private void init(){

//定義球員人名,以數(shù)字代表,從1開(kāi)始

players = new String[n];

for (int i = 0; i players.length; i++) {

//定義球員的名字

players[i] = String.valueOf(i+1);

//存放每個(gè)球員要進(jìn)行的比賽的集合

ListString[] matchList = new LinkedListString[]();

//球員賽事集合

playerMacth.put(players[i], matchList);

//球員集合,不變

// playerListConst.add(players[i]);

}

//定義每個(gè)人的比賽

for (int i = 0; i players.length -1; i++) {

for (int j = i+1; j players.length ; j++) {

String[] match = {players[i],players[j]};//定義一個(gè)比賽

//把此賽事添加到相應(yīng)球員需比賽集合中

playerMacth.get(players[i]).add(match);

playerMacth.get(players[j]).add(match);

}

}

}

/**

* 隨機(jī)獲得一個(gè)當(dāng)前天數(shù)可進(jìn)行的比賽組合,并把此比賽組合從總集合中移除

* 如果當(dāng)前天數(shù)無(wú)比賽,則先獲得比賽,再隨機(jī)

* @author Cris

* @title: getNowDayMatch

* @date 2011-5-24 上午09:48:23

* @return ListString[]

*/

private ListString[] getNowDayMatch(){

if (allMatchData[nowDay] == null) {

setAllMatchNowDay();

}

if (! allMatchData[nowDay].isEmpty()) {

int index = r.nextInt(allMatchData[nowDay].size());

ListString[] list = allMatchData[nowDay].get(index);

allMatchData[nowDay].remove(index);

return list;

}else {

return null;

}

}

/**

* 取消前一天的比賽

* @author Cris

* @title: cancelYesterday

* @date 2011-5-24 上午09:56:12 void

*/

private void cancelYesterday(){

//清空當(dāng)前天數(shù)的可選比賽組合

allMatchData[nowDay] = null ;

//時(shí)間恢復(fù)到前一天

nowDay--;

//獲得前一天的比賽

ListString[] matchList = result.get(nowDay);

//取消前一天的比賽

result.remove(nowDay);

//恢復(fù)每個(gè)運(yùn)動(dòng)員未進(jìn)行的比賽

for(String[] match : matchList){

playerMacth.get(match[0]).add(match);

playerMacth.get(match[1]).add(match);

}

}

public void go(){

//循環(huán)比賽天數(shù)

for ( nowDay = 0; nowDay n -1; ) {

//1.隨機(jī)一個(gè)比賽

ListString[] matchList = getNowDayMatch();

//無(wú)比賽組合 ,返回上一天 取消上一天的比賽,時(shí)間回退到前一天,跳過(guò)此次循環(huán)

if (matchList == null) {

cancelYesterday();

continue;

}

//3遍歷比賽 去除運(yùn)動(dòng)員 去除運(yùn)動(dòng)員的未進(jìn)行比賽

for(String[] match : matchList){

playerMacth.get(match[0]).remove(match);

playerMacth.get(match[1]).remove(match);

}

result.add(matchList);

nowDay++;

}

}

/**

* 從1號(hào)隊(duì)員開(kāi)始,獲得當(dāng)前天數(shù)所有可組合的賽事

* @author Cris

* @title: setAllMatchNowDay

* @date 2011-5-24 上午09:42:51 void

*/

private void setAllMatchNowDay(){

allMatchData[nowDay] = new LinkedListListString[]();

int n = 1;//1號(hào)運(yùn)動(dòng)員

//此運(yùn)動(dòng)員未進(jìn)行的比賽

ListString[] matchList = playerMacth.get(String.valueOf(n));

for(String[] match : matchList){

ListString[] selectedList = new ArrayListString[]();

selectedList.add(match);

doDetAllMatchNowDay(n+1, selectedList);

}

}

/**

* 今天比賽的所有組合

* @author Cris

* @title: doDetAllMatchNowDay

* @date 2011-5-24 上午09:46:05

* @param playerNum

* @param selectedList void

*/

private void doDetAllMatchNowDay(int playerNum,ListString[] selectedList){

//運(yùn)動(dòng)員名稱(chēng)

String player = String.valueOf(playerNum);

boolean flag = true;

//判斷此運(yùn)動(dòng)員是不是已被選過(guò)

for(String[] match : selectedList){

if (match[0].equals(player) || match[1].equals(player)) {

flag = false;

break;

}

}

//已被選過(guò)

if ( flag == false) {

//最后一個(gè)人員

if (playerNum == n) {

allMatchData[nowDay].add(selectedList);

}else{

doDetAllMatchNowDay(playerNum+1, selectedList);

}

return;

}

//此運(yùn)動(dòng)員未進(jìn)行的比賽

ListString[] matchList = playerMacth.get(player);

//此運(yùn)動(dòng)員可選擇的比賽

ListString[] canDoList = new ArrayListString[]();

for(String[] match : matchList){

flag = true;

for(String[] selected : selectedList){

if(match[0].equals(player)){

if(match[1].equals(selected[0])){

flag = false;

}else if(match[1].equals(selected[1])){

flag = false;

}

}else{

if(match[0].equals(selected[0])){

flag = false;

}else if(match[0].equals(selected[1])){

flag = false;

}

}

}

if (flag) {

canDoList.add(match);

}

}

//遍歷此運(yùn)動(dòng)員可選擇的比賽

for(String[] match : canDoList){

ListString[] newList = copyArrayList(selectedList);

//記錄當(dāng)前比賽

newList.add(match);

//最后一個(gè)人員

if (playerNum == n) {

allMatchData[nowDay].add(newList);

}else{

doDetAllMatchNowDay(playerNum+1, newList);

}

}

}

/**

* 復(fù)制集合

* @author Cris

* @title: copyArrayList

* @date 2011-5-24 上午09:24:44

* @param list

* @return ListString[]

*/

private ListString[] copyArrayList(ListString[] list){

ListString[] newList = new ArrayListString[]();

for(String[] s : list){

newList.add(s);

}

return newList;

}

public ListListString[] getResult() {

return result;

}

}


新聞名稱(chēng):java循環(huán)計(jì)算源代碼,java循環(huán)程序代碼
轉(zhuǎn)載注明:http://weahome.cn/article/dsijspo.html

其他資訊

在線咨詢(xún)

微信咨詢(xún)

電話(huà)咨詢(xún)

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部