通常佢想你答佢有@@
小瀑﹏§ 發表於 2-12-2010 10:27 PM http://www4.nakuz.com/bbs/images/common/back.gif
我答有 XD
問佢係邊返工
之後佢叫我返到公司先 再坐公司車去遵理啲補習社幫手
XD我請小瀑 小瀑請我
神乂怒火 發表於 2-12-2010 22:20 http://www.nakuz.com/bbs/images/common/back.gif
@@無所謂#
@@無所謂#
小瀑﹏§ 發表於 2-12-2010 10:30 PM http://www4.nakuz.com/bbs/images/common/back.gif
聖誕搞個網聚囉 aoa
我答有 XD
問佢係邊返工
之後佢叫我返到公司先 再坐公司車去遵理啲補習社幫手 ...
神乂怒火 發表於 2-12-2010 22:29 http://www.nakuz.com/bbs/images/common/back.gif
good=]
做埋個program先再上一上黎
搵人幫我test下個program run唔run到= .=
依部機無java
import java.util.*;
public class xxx {
public static void main(String args[])
{
// int 所有要用既野
int dn;//dn=difficulty_num
int ds;//ds=difficulty_step
int in;//in=inputnum
int ye;//ye=yesno
int out;//out=outputnum
int ch;//ch=checkerro
int guess[]={0,0,0,0};//quwss
int answer[]={0,0,0,0};//answer
int bl;//b=black
int wh;//w=white
Scanner sc = new Scanner(System.in);
System.out.println("Welcome Mastermind ");
do{
String outprint = "";
do{
System.out.print("Choose the maximum number of steps : ");
ds = sc.nextInt();
System.out.print( ds < 1 ? "Your input is wrong!\n ":"");
}while (ds < 1);
do{
System.out.print("Choose the number of digits to guess :");
dn = sc.nextInt();
System.out.print( dn < 1 || dn > 9 ? "Your input is wrong!\n":"");
}
while (dn < 1 || dn > 9);
do{
System.out.print("Player VS Computer (0-Yes / 1-No)? ");
ye = sc.nextInt();
if (ye == 0){
System.out.println("Player2 Starts to guess ---\nType '0' to leave the game.");
for (int a=0;a<=3;a++){
answer = (int)(Math.random()*dn + 1);}}
else if (ye == 1){
do{
System.out.print("Player1 input the answer: ");
in = ch = sc.nextInt();
for (int b=1000,a=0;a<=3 && b>=1;a++,b/=10){
answer = in/b;
in %= b;
if (ch < 1111 || ch > 9999 || answer < 0 || answer > dn){
System.out.println("Your input is wrong!");
ch *= 10000;
break;}}
}while (ch < 1111 || ch > 9999);
for (int line=1;line<=60;line++){
System.out.println();}}
else
System.out.println("Please input 0 or 1 (0-yes / 1-No)!");
}while (ye != 1 && ye != 0);
for (int step=1;step <= ds;step++){
bl=0;
wh=0;
do{
System.out.print("Step " + step + ": Please input your guess: ");
if (in == 0)
break;
for (int a=0,b=1000;a<=3&&b>=1;a++,b/=10){
guess = in/b;
in %= b;
if (out < 1111 || out > 9999 || guess < 0 || guess > dn){
System.out.println("Your input is wrong!");
out *= 10000;
break;}}
}while (out < 1111 || out > 9999);// outputnum <1111 or outputnum >9999
for (int a=0;a<=3;a++)
{
if (guess == answer)
{
bl++;
answer -= 100;
guess -= 100;
}
}
for (int a=0;a<=3;a++)
{
if (guess < 0)
continue;
for (int b=0;b<=3;b++)
{
if (a != b && guess == answer)
{
wh++;//白
answer -= 100;
break;}
}
}
for (int c=0;c<=3;c++){
answer = (answer<0) ? answer+100:answer;
}
outprint += "Guess " + step + ": " + out + "Black: " + bl + "White: " + wh + "\n";
System.out.print(out);
if (bl == 4){
System.out.print("You Win!");
break;
}
System.out.println("=================================\n");
if (step == ds && bl != 4 || out == 0)//step=difficulty_step black=4 or outputnum =0
{
System.out.print("You Lose! The answer is ");
for (int ans=0;ans<=3;ans++)
{
System.out.print(answer);
}
break;
}
}
do{
System.out.print("\nDo you want to continue (0-Yes / 1-No)? ");
ye = sc.nextInt();
System.out.print(ye != 1 && ye != 0 ? "Please input 0 or 1 (0-Yes / 1-No)!":"");
}
while (ye != 0 && ye != 1);
}
while (ye == 0);//yesno = 0
System.out.println("Bye Bye!");
}
}
聖誕搞個網聚囉 aoa
神乂怒火 發表於 2-12-2010 22:32 http://www.nakuz.com/bbs/images/common/back.gif
都好啵:)
都好啵
小瀑﹏§ 發表於 2-12-2010 22:40 http://www4.nakuz.com/bbs/images/common/back.gif
網聚:handshake
good=]
做埋個program先再上一上黎
搵人幫我test下個program run唔run到= .=
依部機無java
import ja ...
小瀑﹏§ 發表於 2-12-2010 10:39 PM http://www4.nakuz.com/bbs/images/common/back.gif
;P 我完全唔識呢啲野
不過我丫哥係高手呢 ==
我完全唔識呢啲野
不過我丫哥係高手呢 ==
神乂怒火 發表於 2-12-2010 22:44 http://www.nakuz.com/bbs/images/common/back.gif
未test過不過應該run到既=. =''
做左咁多野只係做左成份功課既(a)part= .=
網聚
.小夜﹏ 發表於 2-12-2010 22:43 http://www.nakuz.com/bbs/images/common/back.gif
55:P
55
小瀑﹏§ 發表於 2-12-2010 22:50 http://www4.nakuz.com/bbs/images/common/back.gif
味去過..