MuffinMonster

Class Task 60#

Nov 1st, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1. class Program
  2.     {
  3.         public static int EqualNums(double x, double y)
  4.         {
  5.            
  6.             /*int num = 0;
  7.             if (x < 0 || y < 0) return 0;
  8.             if ((x % 10) == (y % 10))
  9.                 num++;
  10.             return num + EqualNums(x / 10, y / 10);*/
  11.             int num = 0;
  12.             if (x < 10 || y < 10)
  13.             {
  14.                 if ((x % 10) == (y % 10))
  15.                     return 1;
  16.             }
  17.             if ((x % 10) == (y % 10))
  18.                 num++;
  19.             return num + EqualNums(x / 10, y / 10);
  20.         }
  21.         static void Main(string[] args)
  22.         {
  23.             Console.WriteLine(EqualNums(1234, 1234));
  24.             Console.ReadLine();
  25.         }
  26.     }
Add Comment
Please, Sign In to add comment