12週目-数字を当てる

1099 ワード

    :

01./*  
02.*             :  
03.* Copyright (c) 2013,            
04.* All rights reserved.  
05.*     :test.cpp  
06.*       :    
07.*     :2013   11 19   
08.*      :v1.0  
09.*              : 
10.*     :   
11.*     :     (  1000     )
12.*     :   
13.*     :  
14.*     :   
15.*/    

#include <iostream>
#include<ctime>
#include<cstdlib>
using namespace std;
int main()
{
    int n,num,sum=1;
    srand(time(0));
    num=rand()%1000;//  1000      num
    while(1)
    {
        cout<<"    :";
        cin>>n;
        if(n>num)
            cout<<"  !"<<endl;
        else if(n<num)
            cout<<"  !"<<endl;
        else
            break;
        sum++;
    }
    cout<<"    "<<sum<<" ,   。"<<endl;
    return 0;
}