Advertisement
Fanta-MindTerror

Ariphmetic Progression

Dec 24th, 2019
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.30 KB | None | 0 0
  1. static void Main(string[] args)
  2.         {
  3.  
  4.             double a, b, c = 0;
  5.  
  6.             do
  7.             {
  8.                 Console.WriteLine("Введите число a");
  9.                 a = Convert.ToDouble(Console.ReadLine());
  10.             } while (a <= 0);
  11.  
  12.             do
  13.             {
  14.                 Console.WriteLine("Введите число b");
  15.                 b = Convert.ToDouble(Console.ReadLine());
  16.             } while (b <= 0);
  17.  
  18.  
  19.             Console.WriteLine("Введите число c");
  20.             double needed = Convert.ToDouble(Console.ReadLine());
  21.             c = needed;
  22.             while (needed != 0) {
  23.  
  24.                 Console.WriteLine("Введите число c");
  25.                 needed = Convert.ToDouble(Console.ReadLine());
  26.                 if (needed != 0)
  27.                 {
  28.                     a = b;
  29.                     b = c;
  30.                     c = needed;
  31.                 }
  32.             }
  33.             Console.WriteLine( ariphmeticProgression(a, b, c) );
  34.             Console.ReadKey();
  35.         }
  36.  
  37.         static bool ariphmeticProgression(double a,double b,double c)
  38.         {
  39.             if( b - a == c - b)
  40.             {
  41.                 return true;
  42.             }
  43.             else
  44.             {
  45.                 return false;
  46.             }
  47.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement