using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
long num=0;//一高精度数值
int n=4; //要去掉的个数
bool isright = false;
Console.Write("请输入一个高精度正整数:");
do
{
try
{
num = Convert.ToInt64(Console.ReadLine());
}
catch
{
Console.Write("输入有误,请重输:");
continue;
}
string temp=num.ToString();
if(temp.Length<=n)
{
Console.Write("该正整数位数小于或等于要抽取的个数,请重输:");
isright=false;
continue;
}
for(int i=0;i<=temp.Length-1;i++)
{
if (temp[i] =='0')
{
Console.Write("输入有误,数值中不能包含数字0!请重输:");
isright = false;
break;
}
else
isright = true;
}
}while(isright==false);
string numstr=num.ToString();
int[] arraya = new int[numstr.Length];
for (int i = 0; i < arraya.Length; i++)
{
arraya[i] = Convert.ToInt32(Convert.ToString(numstr[i]));
}
Array.Sort(arraya);
Array.Reverse(arraya);
for (int i = 0; i < n; i++)
{
for (int j = 0; j < numstr.Length; j++)
{
if (Convert.ToInt32(Convert.ToString(numstr[j])) == arraya[i])
{
numstr = numstr.Remove(j,1);
break;
}
}
}
Console.WriteLine(numstr);
Console.ReadKey();
}
}
}