Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using static System.Collections.Specialized.BitVector32;
- namespace Z_1
- {
- class Program
- {
- enum Methods{
- While=1,
- DoWhile=2
- }
- static void Main(string[] args)
- {
- int q = 1;
- while (q == 1)
- {
- Console.WriteLine("Введите начало диапазона");
- int a = int.Parse(Console.ReadLine());
- Console.WriteLine("Введите конец диапазона");
- int b = int.Parse(Console.ReadLine());
- Console.WriteLine("Выберите способ 1, 2 или 3.");
- int ch = int.Parse(Console.ReadLine());
- switch ((Methods)ch)
- {
- case Methods.While: gerPositiveFromWhile(a, b); break;
- case 2: f2(a, b); break;
- case 3: f3(a, b); break;
- default: Console.WriteLine("Способ не выбран"); break;
- }
- Console.WriteLine("Если хотите продолжить введите 1");
- q = int.Parse(Console.ReadLine());
- }
- }
- static void f1(int a, int b)
- {
- while (a <= b)
- {
- if (a > 0)
- {
- Console.Write(a + " ");
- }
- a++;
- }
- Console.WriteLine("");
- }
- static void f2(int a, int b)
- {
- do
- {
- if (a > 0)
- {
- Console.Write(a + " ");
- }
- a++;
- }
- while (a <= b);
- Console.WriteLine("");
- }
- static void f3(int a, int b)
- {
- for (int i = a; i <= b; i++)
- {
- {
- if (i > 0)
- {
- Console.Write(i + " ");
- }
- }
- }
- Console.WriteLine("");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement