110,534
社区成员
发帖
与我相关
我的任务
分享
public Int32[] Function(Double[] data)
{
Dictionary<Double, Int32> dict = new Dictionary<Double, Int32>();
for (Int32 index = 0; index < data.Length; index++)
{
if (dict.ContainsKey(data[index]))
{
dict[data[index]]++;
}
else
{
dict.Add(data[index], 1);
}
}
Int32[] result = new Int32[data.Length];
for (Int32 index = data.Length - 1; index >= 0; index--)
{
result[index] = dict[data[index]];
dict[data[index]]--;
}
return result;
}
int[] array = new int[] { 1001, 1002, 1001, 1003, 1001, 1004, 1004 };
int[] addInt = new int[array.Length];
for (int i = 0; i < array.Length; i++)
{
addInt[i] = 1;
for (int j = i - 1; j >= 0; j--)
{
if (array[i] == array[j])
{
addInt[i] += addInt[j];
break;
}
}
}
int[] index = new int[array.Count];
Hashtable ht = new Hashtable();
for ( int i = 0; i < array.Count; i++ )
{
int t;
object tmp = ht[array[i]];
if ( tmp == null )
{
t = 1;
ht.Add( array[i], t );
}
else
{
t = ( int )tmp + 1;
ht[array[i]] = t;
}
index[i] = t;
}
int[] ia = new int[] { 1001, 1002, 1001, 1003, 1001, 1004, 1004 };
int[] ic = new int[ia.Length];
Hashtable ht = new Hashtable();
for (int i = 0; i < ia.Length; i++)
{
if (ht.Contains(ia[i].ToString()))
{
ht[ia[i].ToString()] = Convert.ToInt32(ht[ia[i].ToString()]) + 1;
ic[i] = Convert.ToInt32(ht[ia[i].ToString()]);
}
else
{
ht.Add(ia[i].ToString(), 1);
ic[i] = 1;
}
}
int[] ia = new int[] { 1001, 1002, 1001, 1003, 1001, 1004, 1004 };
Hashtable ht = new Hashtable();
for (int i = 0; i < ia.Length; i++)
{
if (ht.Contains(ia[i].ToString()))
{
ht[ia[i].ToString()] = Convert.ToInt32(ht[ia[i].ToString()]) + 1;
}
else
{
ht.Add(ia[i].ToString(), 1);
}
}
int [] addInt=new int[array.count];
for(int i=0;i<array.count;i++)
for(int j=0;j<i;j++)
{
if(array[i]==array[j])
addInt[i]++;
}