标题:菜鸟不懂!请指教!
只看楼主
小夫子
Rank: 2
来 自:哈尔滨
等 级:论坛游民
帖 子:27
专家分:74
注 册:2011-11-17
得分:4 
  static void Main(string[] args)
        {
             Console.WriteLine("依次输入两个数值和一个运算符");
             double y=0;
            double x1 = Convert.ToDouble(Console.ReadLine());
            double x2 = Convert.ToDouble(Console.ReadLine());         
            string  z = Convert.ToString(Console.ReadLine());
            switch(z)
            {
                case "+":
                y = x1 + x2;
                break;
                case "*":
                y = x1 * x2;
                break;
                case "-":
                y = x1 - x2;
                break;
                case "/":
                y = x1 / x2;
                break;
                default:
                    Console.WriteLine("运算符输入错误");
                    break;
            }

            Console.WriteLine(y );
            Console.ReadLine();
        }
2011-11-30 20:01
jj19971130
Rank: 2
等 级:论坛游民
帖 子:35
专家分:69
注 册:2011-11-30
得分:4 
如果是c的话,if后面应该是if (z =="*")才对
2011-11-30 20:04



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-356559-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.594470 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved