Advertisement
Guest User

Exercises 6, section 5

a guest
Nov 22nd, 2014
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.61 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication1
  8. {
  9.     class Range
  10.     {
  11.         static public double number, firstNeg;
  12.         static public bool condition;
  13.         class Program
  14.         {
  15.             static void Main(string[] args)
  16.             {
  17.                 do
  18.                 {
  19.                     number = Convert.ToDouble(Console.ReadLine());
  20.                 }
  21.                 while (number > 0);
  22.                 if (number < 0)
  23.                 {
  24.                     firstNeg = number;
  25.                 }
  26.                 else
  27.                 {
  28.                     Console.WriteLine("В последовательности нет отрицательных чисел");
  29.                     goto Labell;
  30.                 }
  31.                 do
  32.                 {
  33.                     number = Convert.ToDouble(Console.ReadLine());
  34.                     if ((number < 0) & (number == firstNeg))
  35.                     {
  36.                         condition = true;
  37.                     }
  38.                     else condition = false;
  39.                 }
  40.                 while (number != 0);
  41.                 if (condition == true)
  42.                     Console.WriteLine("В данной последовательности отрицательные числа равны");
  43.                 else Console.WriteLine("В данной последовательности отрицательные числа не равны");
  44.                 Labell:
  45.                 Console.ReadKey();
  46.             }
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement