Advertisement
filin

test

Sep 17th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.21 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. using static System.Collections.Specialized.BitVector32;
  7.  
  8. namespace Z_1
  9. {
  10.     class Program
  11.     {
  12.     enum Methods{
  13.         While=1,
  14.             DoWhile=2  
  15.     }
  16.  
  17.         static void Main(string[] args)
  18.         {
  19.             int q = 1;
  20.             while (q == 1)
  21.             {
  22.                 Console.WriteLine("Введите начало диапазона");
  23.                 int a = int.Parse(Console.ReadLine());
  24.                 Console.WriteLine("Введите конец диапазона");
  25.                 int b = int.Parse(Console.ReadLine());
  26.                 Console.WriteLine("Выберите способ 1, 2 или 3.");
  27.                 int ch = int.Parse(Console.ReadLine());
  28.                 switch ((Methods)ch)
  29.                 {
  30.                     case Methods.While: gerPositiveFromWhile(a, b); break;
  31.                     case 2: f2(a, b); break;
  32.                     case 3: f3(a, b); break;
  33.                     default: Console.WriteLine("Способ не выбран"); break;
  34.                 }
  35.                 Console.WriteLine("Если хотите продолжить введите 1");
  36.                 q = int.Parse(Console.ReadLine());
  37.             }
  38.         }
  39.         static void f1(int a, int b)
  40.         {
  41.             while (a <= b)
  42.             {
  43.                 if (a > 0)
  44.                 {
  45.                     Console.Write(a + " ");
  46.                 }
  47.                 a++;
  48.             }
  49.             Console.WriteLine("");
  50.         }
  51.         static void f2(int a, int b)
  52.         {
  53.             do
  54.             {
  55.                 if (a > 0)
  56.                 {
  57.                     Console.Write(a + " ");
  58.                 }
  59.                 a++;
  60.             }
  61.             while (a <= b);
  62.             Console.WriteLine("");
  63.         }
  64.         static void f3(int a, int b)
  65.         {
  66.             for (int i = a; i <= b; i++)
  67.             {
  68.                 {
  69.                     if (i > 0)
  70.                     {
  71.                         Console.Write(i + " ");
  72.                     }
  73.                 }
  74.             }
  75.             Console.WriteLine("");
  76.         }
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement