第四周 猜数字游戏



#include"iostream"
using namespace std;
#include"ctime"
#include"cstdlib"
int main()
{
    int a;
    srand((unsigned)time(0));
     a=1+rand()%1000;
     cout<     int z=0;
   for(;;)
   {
       cout<<"请猜数"<     int b;
    cin>>b;

        if(a>b)
        {
            cout<<"小了"<             z++;
        }
        else if(a==b)
        {
            z++;
            cout<<"对了,猜了"<             break;
        }
        else
        {
            cout<<"大了";
            z++;
        }
   }
    return 0;
}

你可能感兴趣的:(第四周 猜数字游戏)