D大调
static void Main(string[] args)
{
int[] arr = new int []{3,3,2,1,5,4,5,5,2,2,4,3 };
List<int> list = new List<int>();
for (int i = 0; i < arr.Length;i++ )
{
if(!list.Contains(arr[i])){
list.Add(arr[i]);
}
}
foreach (int item in list)
{
Console.Write(item);
Console.Write(",");
}
Console.ReadKey();
Dictionary<int, int> dd = new Dictionary<int, int>();
for (int i = 0; i < arr.Length; i++)
{
int count = 1;
for (int j = i + 1; j < arr.Length;j++ )
{
if (arr[i] == arr[j])
{
count++;
}
}
if(dd.Keys.Contains(arr[i]))
{
continue;
}
else
{
dd.Add(arr[i], count);
}
}
int count1 = 0;
foreach (int item in dd.Keys)
{
if (dd[item] == 1)
{
count1++;
}
else {
Console.WriteLine("{0}:{1}", item, dd[item]);
}
}
Console.WriteLine("不重复的数字的数量{0}", count1);
Console.ReadLine();
}