都 BS你了!我不BS你 会被他们BS的!所以 BS一下你!

解决方案 »

  1.   

    我就不参与bs的队伍了,
    首先你要考虑你准备怎么输入和输出,是做一个form界面还是一个控制台程序
    确定了请继续
      

  2.   


    Class Program
    {
       static void Main()
       {
          bool isOpt = true      while(isOpt)
          {
             string str = Console.ReadLine();
             if(Math.IsInteger(str))
             {
                string[] data = str.Split(' ');
                int a = Convert.ToInt32(data[0]);
                int b = Convert.ToInt32(data[1]);            Console.WriteLine(Math.Sum(a,b));            Console.WriteLine("是否继续计算(Y/N):");
                isOpt = (Console.ReadLine().Trim().ToUpper() == "Y");
             }
             else
             {
                Cosnole.WriteLine("输入格式不正确,请重新输入:");
             }
          }
       }
    }Class Math
    {
       public static bool IsInteger(string str)
       {
          bool isInteger = true;
          int i = 0;      while(isInteger)
          {
             isInteger = (Char.ConvertToUtf32(str,i) >= 48 && Char.ConvertToUtf32(str,i) <= 57 || Char.ConvertToUtf32(str,i) == 32);
             i++;
          }      return isInteger;
       }   public static int Sum(int a, int b)
       {
          return a + b;
       }
    }
      

  3.   

    BS懒于自己思考的和让别人懒于思考的以及不BS该BS的
      

  4.   

    int Calculate(int x,int y)
    {
       return x+y;
    }//orint Calculate(int x,int y)
    {
      return (int)System.Math.Sum(x,y);
    }
      

  5.   

     static void Main(string[] args)
            {                       int a=0, b=0;
                string stra, strb;
                Boolean isInt32=false;
               
                while (isInt32 ==false)
                {
                    Console.WriteLine("请输入第一个数:");
                    stra = Console.ReadLine();
                    if (Int32.TryParse(stra, out a))
                    {                    
                        isInt32 = true;
                    }
                    else
                    {
                        Console.WriteLine("输入错误,请再输入:");
                    }
                }                                 isInt32=false;
                while (isInt32 == false)
                {
                    Console.WriteLine("请输入第二个数:");
                    strb = Console.ReadLine();
                    if (Int32.TryParse(strb, out b))
                    {                    
                        isInt32 = true;
                    }
                    else
                    {
                        Console.WriteLine("输入错误,请再输入:");
                    }
                }            Console.WriteLine("两个数的和为:{0}",a+b);            Console.ReadLine();            
            }
      

  6.   

    兄弟我不鄙视你,我和你一样也是新手,其实只要多做的话
    自己也能做出来的
    这是我刚做的
    using System;
    using System.Collections.Generic;
    using System.Text;namespace test0501_原创加法_
    {
        class Program
        {
            static void Main(string[] args)
            {
                int a, b;
                string yes = "y";
                while (yes == "y"||  yes =="Y")
                {
                   try 
                    {
                        Console.Write("请输入第一个数:");
                        a = int.Parse(Console.ReadLine());
                        Console.Write("请输入第二个数:");
                        b = int.Parse(Console.ReadLine());
                    }
                    catch (System.FormatException)
                    {
                        Console.WriteLine("你输入的不是一个整数");
                        continue;
                    }
                    
                    Console.WriteLine("这两个数的和为:{0}",a+b);
                    Console.WriteLine("是否继续计算,是请按“y”或“Y”");
                    yes = Console.ReadLine();
                }        }
        }
    }
      

  7.   

    我也BS那些给答案的:
    看看给的那些代码,都是垃圾。
    连构造函数和重载可能都不清楚,最基本的OO思想都没有,还好意思给别人答案。
      

  8.   

    第一点后半句有点不明白
    第二点:好办,你对它进行system.math.abs()一下,再乘一个-1进行了比较就可以得到它是否为整数
    第三点:这也好办:你把值返回回去,弹出一个框让其选择.需要相加则再把已加好的值传入,再传入其它的值就OK
      

  9.   

    public class Math
      {
        private Int32 m_a;
        private Int32 m_b;    public void CheckInputInteger() {
          Int32 a,b;
          Boolean inputOk=false;      while (inputOk == false) {
            Console.WriteLine("Input integer:");
            Int32.TryParse(Console.ReadLine(), out a);
            Int32.TryParse(Console.ReadLine(), out b);        if (a != 0 && b != 0) {
              inputOk = true;
              this.m_a = a;
              this.m_b = b;
            }
            else
              inputOk = false;
          }
        }    public Int32 Sum() {
          return this.m_a + this.m_b;
        }
      }