test

#include <iostream>
#include <vector>
using std::cout;
using std::cin;
using std::vector;

vector<int> v;
int right, position, count=0;

int main()
{
    cout << "Now guess your number in mind is # # # #. ";
    for(int i =1; i <=9; ++i)
    {
        cout << "I guess: " << i << " " << i << " " << i << " " << i << "\n";
        count++;
        cin >> right;// >> position;
        if(right > 0)
        {
            for(int idx=0; idx<right;++idx)
            {
                v.push_back(i);
            }
        }
        if(v.size() == 4)
            break;
    }

    cout << "now 4 digits is :" << v[0] << "," << v[1] << "," << v[2] << "," << v[3] << ".\n";

    for(int i=0; i < 4; ++i)
    {

        for(int j=0; j < 4; ++j)
        {
            if(j==i)
            {
                continue;
            }
            for(int k=0; k <4; ++k )
            {
                if(k==i || k==j)
                {
                    continue;
                }
                for(int l=0; l < 4; ++l)
                {
                    if(l==i || l==j || l==k)
                    {
                        continue;
                    }
                    cout << "I guess: " << v[i] << " " << v[j] << " " << v[k] << " " << v[l] << "\n";
                    count++;
                    cin >> position;/*right >>*/
                    if(position == 4)
                    {
                        cout << "Totally " << count << " pass!";
                        system("PAUSE");
                        return 0;
                    }
                }
            }
        }
    }
}

posted @ 2007-11-01 03:58  中土  阅读(224)  评论(2编辑  收藏  举报
©2005-2008 Suprasoft Inc., All right reserved.