yakovmonarh

Загадка ШРАМ * Ы = МАРШ

Dec 11th, 2019
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Riddle
  4. {
  5.     class Program
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             int Ш, Р, А, М, Ы;
  10.             int ШРАМ,
  11.             МАРШ;
  12.            
  13.             for(Ш = 0; Ш <= 9; Ш++)
  14.                 for(Р = 0; Р <= 9; Р++)
  15.                     if(Р != Ш)
  16.                         for(А = 0; А <= 9; А++)
  17.                             if(А != Р && А != Ш)
  18.                                 for(М = 0; М <= 9; М++)
  19.                                     if(М != А && М != Р && М != Ш)
  20.                                         for(Ы = 0; Ы <= 9; Ы++)
  21.                                         {
  22.                                             if(Ы != М && Ы != А && Ы != Р && Ы != Ш)
  23.                                             {
  24.                                                 ШРАМ = Ш * 1000 + Р * 100 + А * 10 + М;
  25.                                                 МАРШ = М * 1000 + А * 100 + Р * 10 + Ш;
  26.                                                 if(ШРАМ * Ы == МАРШ)
  27.                                                 {
  28.                                                     Console.WriteLine(М.ToString() + А.ToString() + Р.ToString() + Ш.ToString());
  29.                                                 }
  30.                                             }
  31.                                                
  32.                                         }
  33.                    
  34.             Console.ReadLine();
  35.         }
  36.     }
  37. }
Add Comment
Please, Sign In to add comment