Advertisement
Aliendreamer

problem from Softuni

May 22nd, 2018
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.22 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.      public  class Program
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             HashSet<int>normalNumbers=new HashSet<int>();
  10.             StringBuilder sb=new StringBuilder();
  11.             for(int i=10;i<100;i++)
  12.             {  
  13.                 for(int j=10;j<100;j++)
  14.                 {
  15.             int m=i;
  16.             int n=j;
  17.                    
  18.             char[]reverseTwo=n.ToString().ToCharArray();
  19.             Array.Reverse(reverseTwo);
  20.             string getIntTwo=string.Concat(reverseTwo);
  21.            
  22.             char[]reverse=m.ToString().ToCharArray();
  23.             Array.Reverse(reverse);
  24.             string getInt=string.Concat(reverse);
  25.                    
  26.             int b=int.Parse(getInt);
  27.             int a=int.Parse(getIntTwo);
  28.             int mXnResult=m*n;
  29.             int aXbResult=a*b; 
  30.                    
  31.             bool Even=mXnResult==aXbResult;    
  32.                    
  33.                     if(Even)
  34.                     {
  35.                         normalNumbers.Add(n);
  36.                         normalNumbers.Add(m);
  37.                         normalNumbers.Add(a);
  38.                         normalNumbers.Add(b);
  39.                         string evenPairs=string.Format("{0}*{1}={2}*{3} ={4}",n,m,a,b,aXbResult);
  40.                         sb.AppendLine(evenPairs);
  41.                        
  42.                     }
  43.                    
  44.                 }
  45.             }
  46.             Console.WriteLine(string.Join(" ",normalNumbers.OrderBy(x=>x)));
  47.             Console.WriteLine();
  48.             Console.WriteLine(sb.ToString().TrimEnd());
  49.            
  50.            
  51.         }
  52.              
  53.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement