Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.76 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6.  
  7. namespace ConsoleApplication1
  8. {
  9.    class Program
  10.      {
  11.  
  12.        static int N;
  13.        static int i = 0;
  14.        static int edinici;
  15.        static int desetici;
  16.        static int stotici;
  17.        static int hilqdi;
  18.  
  19.        static void Decode(int input)
  20.        {
  21.  
  22.  
  23.            hilqdi = input / 1000;
  24.            input = input % 1000;
  25.  
  26.            stotici = input / 100;
  27.            input = input % 100;
  28.  
  29.            desetici = input / 10;
  30.            input = input % 10;
  31.  
  32.            edinici = input;
  33.        }
  34.  
  35.        static bool Test()
  36.         {
  37.             if (hilqdi > 0)
  38.             {
  39.                 if (N % hilqdi > 0)
  40.                     return false;
  41.             }
  42.             else
  43.                 return false;
  44.  
  45.             if (stotici > 0)
  46.             {
  47.                 if (N % stotici > 0)
  48.                     return false;
  49.             }
  50.             else
  51.                 return false;
  52.  
  53.             if (desetici > 0)
  54.             {
  55.                 if (N % desetici > 0)
  56.                     return false;
  57.             }
  58.             else
  59.                 return false;
  60.  
  61.             if (edinici > 0)
  62.             {
  63.                 if (N % edinici > 0)
  64.                     return false;
  65.             }
  66.             else
  67.                 return false;
  68.            
  69.             return true;
  70.         }
  71.  
  72.  
  73.         static void Main(string[] args)
  74.         {
  75.  
  76.  
  77.             N = int.Parse(Console.ReadLine());
  78.            
  79.             for (i = 1111; i < 10000; i++)
  80.             {
  81.                 Decode(i);
  82.                 if (Test())
  83.                 {
  84.                     Console.Write(i + " ");
  85.                 }
  86.             }
  87.         }
  88.     }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement