zoukankan      html  css  js  c++  java
  • 每日总结

     

    #include <iostream>
    #include <time.h>
    using namespace std;
    class game
    {
    public:
    int h,m,s,sum;
    void input(){cout<<"请输入游戏时间(时分秒):"<<endl;cin>>h>>m>>s;}
    void guess();
    game(){}
    ~game(){}
    };
    void game::guess ()
    {
    sum=h*3600+m*60+s;
    srand((int)time(0));
    int n;
    n=rand()%10000+1;
    time_t start,end;

    while(1)
    {
    start=time(NULL);
    cout<<"游戏开始!数字范围1~10000,游戏时间:"<<sum<<"s,时间耗尽前未猜出数字则输,猜出就赢"<<endl;
    while(1)
    {
    end=time(NULL);
    int a;
    cout<<"输入数字:"<<endl;
    cin>>a;
    if(a<n) {cout<<"低了哦!"<<endl;}
    else if(a>n) {cout<<"高了哦!"<<endl;}
    else {cout<<"恭喜你,你赢了!"<<endl;return;}
    if(end-start>=sum) {cout<<"时间到,游戏结束"<<endl;cout<<"这个数字是:"<<n<<endl;return ;}
    }
    }
    }
    int main()
    {
    game a;
    char b;
    for(;;)
    {
    cout<<"是否开始游戏:A 、是 B、否"<<endl;
    cin>>b;
    if(b=='A')
    {
    a.input ();
    a.guess ();
    break;
    }
    }
    return 0;
    }

  • 相关阅读:
    CF1011B
    CF1011A
    AHOI2009 中国象棋
    jsp九大内置对象
    jsp七大动作指令
    navicat从下载到使用
    javaWeb应用部署结构浅析
    tomcat从下载到使用
    JavaWEB前端向服务器端发送对象
    初学者对Spring MVC的认识
  • 原文地址:https://www.cnblogs.com/ldy2396/p/14159337.html
Copyright © 2011-2022 走看看