Advertisement
Silviya7

6. Substitute

Aug 15th, 2022
1,032
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.06 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Substitute
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.            
  10.             int k= int.Parse(Console.ReadLine());
  11.             int l= int.Parse(Console.ReadLine());
  12.             int m= int.Parse(Console.ReadLine());
  13.             int n= int.Parse(Console.ReadLine());
  14.  
  15.             bool isequal = false;
  16.             bool isvalidcomb = false;
  17.  
  18.  
  19.  
  20.             string firstnumber = "";
  21.             string secondnumber = "";
  22.  
  23.             int countvalicomb = 0;
  24.  
  25.             //Calculations
  26.             for (int firstdig = k; firstdig <= 8; firstdig++)// pyrva cifra ot 1 nomer
  27.             {
  28.                 for (int seconddig = 9; seconddig >= l; seconddig--)// 2 cifra
  29.                 {
  30.  
  31.                     for (int firstdigsec = m; firstdigsec <= 8; firstdigsec++)// 1 cifra 2 4islo
  32.                     {
  33.                         for (int secdigsec = 9; secdigsec >= n; secdigsec--)
  34.                         {
  35.                             if(firstdig % 2==0 && firstdigsec % 2 == 0 && seconddig % 2 == 1 && secdigsec % 2 ==1)// 1 cifra trqbva da e 4etna i 2 -ne4etna
  36.                             {
  37.  
  38.                                // countvalicomb++;
  39.  
  40.                                 isvalidcomb = true;
  41.                                
  42.                             }
  43.                             else
  44.                             {
  45.                                 continue;
  46.                             }
  47.  
  48.                             firstnumber=firstdig.ToString()+ seconddig.ToString();
  49.                             secondnumber = firstdigsec.ToString() + secdigsec.ToString();
  50.                             if (firstnumber == secondnumber)
  51.                             {
  52.                                 isequal = true;// syvpadat
  53.                                 Console.WriteLine($"Cannot change the same player.");
  54.                                 continue;
  55.                             }
  56.                             else
  57.                             {
  58.                                 isequal = false;
  59.                                 if (isvalidcomb == true && isequal == false)
  60.                                 {
  61.                                     countvalicomb++;
  62.                                 }
  63.  
  64.                                 Console.WriteLine($"{firstdig}{seconddig} - {firstdigsec}{secdigsec}");
  65.                             }
  66.  
  67.                             if (countvalicomb == 6)
  68.                             {
  69.                                 break;
  70.                             }
  71.                         }
  72.                         if (countvalicomb == 6)
  73.                         {
  74.                             break;
  75.                         }
  76.                     }
  77.                     if (countvalicomb == 6)
  78.                     {
  79.                         break;
  80.                     }
  81.  
  82.                 }
  83.                 if (countvalicomb == 6)
  84.                 {
  85.                     break;
  86.                 }
  87.  
  88.             }
  89.             //End
  90.  
  91.  
  92.  
  93.         }
  94.     }
  95. }
  96.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement