Проверка чисел на совпадение цифр между ними - C#
Формулировка задачи:
Помогите!
Нужно вводить в консоли два числа
а программа ищет совпадения (какие цифры совпали)
За ранее спасибо...
Решение задачи: «Проверка чисел на совпадение цифр между ними»
textual
Листинг программы
using System;
using System.Linq;
using System.Collections.Generic;
namespace Application
{
class MainClass
{
static bool IsMatchWithDigit (int number, int digit)
{
do
{
if (number % 10 == digit)
return true;
number/=10;
}
while (number!=0);
return false;
}
public static void Main (string[] args)
{
int a = int.Parse (Console.ReadLine ());
int b = int.Parse (Console.ReadLine ());
List<int> result = new List<int> ();
do
{
if (IsMatchWithDigit (b, a % 10) && !result.Contains (a % 10))
{
result.Add (a % 10);
}
a/=10;
}
while (a!=0);
foreach (int item in result)
{
Console.WriteLine (item);
}
}
}
}