美文网首页
期中考试第四小题

期中考试第四小题

作者: 流影随风 | 来源:发表于2018-11-23 15:33 被阅读0次

    #编码

    Console.WriteLine("点击率统计");

                try

                {

                    string str_a = "";

                    int a = 0;

                    int b = 0;

                    for (int i = 1; i <= 4; i++)

                    {

                        Console.Write("第{0}个点击率是:", i);

                        str_a = Console.ReadLine();

                        a = Convert.ToInt32(str_a);

                        if (a > 100)

                        {

                            b++;

                        }

                    }

                    Console.WriteLine("超过100的有{0}个", b);

                    double c = b / 4.0;

                    String d = c.ToString("P");

                    Console.Write("超过100占比:{0}", d);

                }

                catch

                {

                    Console.WriteLine("输入错误");

                }

                Console.ReadKey();

    #效果

    相关文章

      网友评论

          本文标题:期中考试第四小题

          本文链接:https://www.haomeiwen.com/subject/qhvjqqtx.html