zoukankan      html  css  js  c++  java
  • 【005】优化猜数游戏

    【题目】改进猜数游戏程序,功能是: 

    a.允许用户反复输入数,直至猜中程序选定的数。

    b.输入的数如果大于选定的数,则提示“太大了”;如果小于选定的数,则提示“太小了”; 如果等于选定的数,则输出“你赢了”并结束程序。

    【解答】

    #include<iostream>

    using namespace std;

    int main()

    {

     int a;

     cin>>a;

     while(a!=5)

     {

      if(a<5)

       cout<<"太小了"<<endl;

      else

       cout<<"太大了"<<endl;

      cin>>a;

     }

     cout<<"你赢了!"<<endl;

     return 0;

    }

  • 相关阅读:
    MySQL数据库基础
    Django框架
    Python基础
    C#
    小功能
    数据结构与算法
    C语言
    Robot Framework高级
    Robot Framework初级
    C++基础
  • 原文地址:https://www.cnblogs.com/leopotter/p/4866671.html
Copyright © 2011-2022 走看看