2018-11-21

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace ConsoleApplication4

{

    class Program

    {

        static void Main(string[] args)

        {

            string strNumber = "";//存储的用户的输入

            do

            {

                Console.WriteLine("请输入数字");

                strNumber = Console.ReadLine();//数字  q    乱七八糟

                if (strNumber != "q")//数字  乱七八糟

                {

                    try

                    {

                        int number = Convert.ToInt32(strNumber);

                        Console.WriteLine("这个数字的2倍是{0}", number * 2);

                    }

                    catch//输入的是乱七八糟

                    {

                        Console.WriteLine("输入有误,请重新输入");

                    }

                }

                else//==q

                {

                    Console.WriteLine("你输入的是q,程序退出!!!");

                }

            } while (strNumber != "q");

            Console.ReadKey();

        }

    }

}

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • using System; using System.Collections.Generic; using Sys...
    零二幺五阅读 238评论 0 0
  • using System; using System.Collections.Generic; using Sys...
    南川_3193阅读 118评论 0 0
  • 循环结构 要么痛苦的坚持游戏结束 可能会升级 要么结束游戏继续的痛苦 可能有遗憾 知识点 (1) . whil...
    拾起_518阅读 420评论 0 0
  • using System; using System.Collections.Generic; using Sys...
    追魂_409e阅读 161评论 0 0
  • 这个周末我们没回老家, 周五晚上,和周六一整天,我都在学习魔方。到现在我学会了三种魔方,孙子淳学会了五种魔方。 我...
    轩小豆阅读 258评论 0 0

友情链接更多精彩内容