Advertisement
Guest User

Untitled

a guest
Feb 16th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.25 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _05._Multiplication_Sign
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double num1 = double.Parse(Console.ReadLine());
  10.             double num2 = double.Parse(Console.ReadLine());
  11.             double num3 = double.Parse(Console.ReadLine());
  12.             Console.WriteLine(CheckMultiplyResult(num1, num2, num3));
  13.         }
  14.  
  15.         private static string CheckMultiplyResult(double num1, double num2, double num3)
  16.         {
  17.             double[] arr = { num1, num2, num3 };
  18.             string result;
  19.             int negativeCounter = 0;
  20.             bool zero = false;
  21.             for (int i = 0; i < 3; i++)
  22.             {
  23.                 if (arr[i] == 0)
  24.                 {
  25.                    zero = true;
  26.                 }
  27.                 else if (arr[i] < 0)
  28.                 {
  29.                     negativeCounter++;
  30.                 }
  31.             }
  32.             if (zero)
  33.             {
  34.                 result = "zero";
  35.             }
  36.             else if (negativeCounter % 2 != 0)
  37.             {
  38.                 result = "negative";
  39.             }
  40.             else
  41.             {
  42.                 result = "positive";
  43.             }
  44.             return result;
  45.  
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement