Advertisement
ret_0

c# egor prac 4 num 3 var 11

Oct 15th, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.42 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace egor_prac4_z3_var11
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             int a, b, x, y, i;
  13.             Console.Write("from A to B which ends with X or Y\n\nEnter\nA = ");
  14.             a = int.Parse(Console.ReadLine());
  15.             Console.Write("B = ");
  16.             b = int.Parse(Console.ReadLine());
  17.             Console.Write("X = ");
  18.             x = int.Parse(Console.ReadLine());
  19.             Console.Write("Y = ");
  20.             y = int.Parse(Console.ReadLine());
  21.  
  22.             Console.Write("\nfor:\n");
  23.             for (i = a; i <= b; i++)
  24.             {
  25.                 if (i % 10 == x || i % 10 == y)
  26.                 {
  27.                     Console.Write(i + " ");
  28.                 }
  29.             }
  30.  
  31.             Console.Write("\n\nwhile:\n");
  32.             i = a;
  33.             while(i <= b)
  34.             {
  35.                 if (i % 10 == x || i % 10 == y)
  36.                 {
  37.                     Console.Write(i + " ");
  38.                 }
  39.                 i++;
  40.             }
  41.  
  42.             Console.Write("\n\ndo-while:\n");
  43.             i = a;
  44.             do
  45.             {
  46.                 if (i % 10 == x || i % 10 == y)
  47.                 {
  48.                     Console.Write(i + " ");
  49.                 }
  50.             } while (i++ < b);
  51.  
  52.             Console.ReadKey();
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement