class Program
{
static void Main(string[] args)
{
int num, rem, lenth = 0, temp = 0, n, max, input;
Console.WriteLine("Enter the input number");
num = n = input = int.Parse(Console.ReadLine());
while (num > 0)
{
num = num / 10;
lenth++;
}
int[] arr = new int[lenth];
max = arr[0];
while (n > 0)
{
rem = n % 10;
n = n / 10;
if (rem == 0)
{
Console.WriteLine("The given number is not pan digit number");
return;
}
else
{
for (int k = 0; k < arr.Length; k++)
{
if (arr[k] != 0)
{
if (rem == arr[k])
{
Console.Write("Given number is not pandigit number");
return;
}
}
else
{
arr[temp] = rem;
temp++;
if (arr[k] > max)
{
max = arr[k];
break;
}
}
}
}
if (lenth == max)
{
Console.WriteLine("The given number is pandigital number");
}
else
{
Console.WriteLine("The given pandigit number is not pandigi number");
}
Console.ReadLine();
}
}
}
OUTPUT:
No comments:
Post a Comment