Advertisement
Spocoman

Barcode Generator

Dec 9th, 2021 (edited)
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.92 KB | None | 0 0
  1. using System;
  2.  
  3. namespace BarcodeGenerator
  4. {
  5.     class Program
  6.     {
  7.         public static void Main()
  8.         {
  9.             int startNum = int.Parse(Console.ReadLine());
  10.             int finalNum = int.Parse(Console.ReadLine());
  11.  
  12.             for (int a = (int)(startNum / 1000); a <= (int)(finalNum / 1000); a++)
  13.             {
  14.                 for (int b = (int)(startNum / 100) % 10; b <= (int)(finalNum / 100) % 10; b++)
  15.                 {
  16.                     for (int c = (int)(startNum / 10) % 10; c <= (int)(finalNum / 10) % 10; c++)
  17.                     {
  18.                         for (int d = startNum % 10; d <= finalNum % 10; d++)
  19.                         {
  20.                             if (a % 2 == 1 && b % 2 == 1 && c % 2 == 1 && d % 2 == 1)
  21.                             {
  22.                                 Console.Write($"{a}{b}{c}{d} ");
  23.                             }
  24.                         }
  25.                     }
  26.                 }
  27.             }
  28.         }
  29.     }
  30. }
  31.  
  32. ИЛИ:
  33.  
  34. using System;
  35.  
  36. namespace BarcodeGenerator
  37. {
  38.     class Program
  39.     {
  40.         public static void Main()
  41.         {
  42.             string startNum = Console.ReadLine();
  43.             string finalNum = Console.ReadLine();
  44.  
  45.             for (int a = startNum[0]; a <= finalNum[0]; a++)
  46.             {
  47.                 for (int b = startNum[1]; b <= finalNum[1]; b++)
  48.                 {
  49.                     for (int c = startNum[2]; c <= finalNum[2]; c++)
  50.                     {
  51.                         for (int d = startNum[3]; d <= finalNum[3]; d++)
  52.                         {
  53.                             if ((char)a % 2 == 1 && (char)b % 2 == 1 && (char)c % 2 == 1 && (char)d % 2 == 1)
  54.                             {
  55.                                 Console.Write($"{(char)a}{(char)b}{(char)c}{(char)d} ");
  56.                             }  
  57.                         }
  58.                     }
  59.                 }
  60.             }
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement