首页 > 代码库 > c#加法算乘积

c#加法算乘积

    class Program
    {
        static void Main(string[] args)
         {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            a = a < 0 ? -a : a;
           
            int c = 0;
            for (int i = 1; i <= a; i++)
              {
                c += b;
              }

            if (a < 0 && b < 0)
            {
                c = -c;
            }
            Console.WriteLine(c);
            Console.Read();
     
        }
    }

c#加法算乘积