这不就是猜数字的游戏吗,很多手机上有!!!这和Jbuilder什么关系???应该是求一个算法吧!!!挺有创意的,自己想吧,帮不上你!!!

解决方案 »

  1.   

    猜数字游戏的算法,google上搜去吧多的是
      

  2.   

    给你一个我写的C程序,很容易转成java代码
    //猜数字游戏#include<iostream.h>
    #include<stdlib.h>
    #include<conio.h>
    #include<time.h>int N;
    char result[10]="123456789";
    int a,b;
    void  product()
    {
        char temp;
        int t;    srand(time(0));    //产生真正的随机数    for(int i=0;i<N;i++)
        {
            t=rand()%9;
            if(t!=i)
            {
                temp=result[i];
                result[i]=result[t];
                result[t]=temp;
            }
        }
    }void check(char *user)
    {
        a=b=0;
        for(int i=0;i<N;i++)
        {
            for(int j=0;j<N&&*(result+i)!=*(user+j);j++);
            if(j==i)
                a++;
            else if(j!=N)
                b++;
        }
    }
    void input(char *user)
    {
        char ch;
        int k;
        cout<<"Please input "<<N<<" numbers:"<<endl;
        for(int i=0;i<N;i++)
        {
            do
            {
                k=0;
                ch=getch();
                for(int j=0;j<i&&!k;j++)
                {
                    if(*(user+j)==ch)
                        k=1;
                }
            }while(ch<'1'||ch>'9'||k);
            *(user+i)=ch;
            cout<<ch<<flush;
        }
                
    }
    void main()
    {
        char *user;
        int count;
        char key;
        cout<<"Welcome to use GuessNumber game!"<<endl;
        do
        {
            cout<<"Please select the difficulty:"<<flush;
            do
            {
                N=getch()-'0';
            }while(N<1);
            cout<<N<<endl;        user=new char[N];
        
            count=0;
            product();
            do
            {
                input(user);
                check(user);
                cout<<'\t'<<a<<'A'<<b<<'B'<<endl;
                count++;
            }while(a!=N);
            cout<<"Congratulations!You get it by guessing for "<<count<<" times."<<endl;
            cout<<"Would you like to try again?(y/n) "<<flush;
            do
            {
                key=getch();
            }while(key!='y'&&key!='n');
            cout<<key<<endl;
        }while(key=='y');
        cout<<"Thanks for using!"<<endl;}
      

  3.   

    如果楼主用了楼上的c程序.那么就得转化成Java了,
    ^_^...赶紧搜索以前得相关程序吧.我有的回答的啊!