如何打印双色球所有的注数
双色球一共有17721088注,怎么通过java实现把所有的注数显示出来呢,谢谢。 --------------------编程问答-------------------- 就是一个穷举的排列,用递归或者多层循环就可以了 --------------------编程问答-------------------- 穷举就是一个排列组合 估计打印要好长时间. --------------------编程问答-------------------- 就用while跟for用遞迴就可以了 --------------------编程问答-------------------- 我到想用穷举,递归,能说具体些不。 --------------------编程问答-------------------- 就是穷举 用递归实现
都打印全部了
还能有什么好方法 --------------------编程问答-------------------- C(6,33)=33!/(33-6)!/6!。 --------------------编程问答--------------------
这个是组合的公司啊,还要*16能算出17721088注,但是不能打印出来所有的注数。 --------------------编程问答-------------------- 服务端
import java.net.*;
import java.io.*;
import java.util.*;
class fanserver
{
static List<fanclient> client = new ArrayList<fanclient>();
public static void main(String[] args)throws Exception
{
Socket s;
ServerSocket ss = new ServerSocket(4445);
while(true){
s = ss.accept();
System.out.println("haha...");
server ser = new server(s);
new Thread(ser).start();
client.add(ser);
}
/* BufferedReader br =
new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bwout =
new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
BufferedReader brin =
new BufferedReader(new InputStreamReader(s.getInputStream()));
String str = null;
while((str=brin.readLine())!=null){
// System.out.println(str);
bwout.write(str);
bwout.flush();
bwout.newLine();
}
*/
// s.shutdownOutput();
}
}
class server implements Runnable
{
private Socket s;
server(Socket s){
this.s = s;
}
public void run(){
try{
BufferedWriter bwout =
new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
BufferedReader brin =
new BufferedReader(new InputStreamReader(s.getInputStream()));
String str = null;
while((str=brin.readLine())!=null){
System.out.println(str);
bwout.write(str);
bwout.newLine();
bwout.flush();
}
// s.shutdownOutput();
}
catch(Exception e){}
}
}
Java code客户端
import java.net.*;
import java.io.*;
class fanclient
{
public static void main(String[] args)throws Exception
{
Socket s = new Socket("192.168.30.129",4445);
BufferedReader br =
new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bwout =
new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
BufferedReader brin =
new BufferedReader(new InputStreamReader(s.getInputStream()));
new Thread(new client(brin)).start();
String str = null;
while((str=br.readLine())!=null){
bwout.write(str);
bwout.newLine();
bwout.flush();
}
// s.shutdownOutput();
// String line = brin.readLine();
// System.out.println(line);
}
}
class client implements Runnable
{
private BufferedReader brin;
client(BufferedReader brin)
{
this.brin = brin;
}
public void run(){
String line = null;
try{
while((line=brin.readLine())!=null){
System.out.println(line);
}
}catch(Exception e){}
}
}
我同时启动好几个客户端,想让客户端通过服无端互相接收到信息,怎么处理,
--------------------编程问答-------------------- 呵呵,你另开贴讨论吧,我也搞不懂你的。
补充:Java , Java SE