110,533
社区成员
发帖
与我相关
我的任务
分享
public static int GetCommonCharCount(int[] a, int[] b)
{
Array.Sort(a);
Array.Sort(b);
int commonCount = 0;
for (int i = 0, j = 0; i < a.Length && j < b.Length; )
{
if (a[i] < b[j])
{
i++;
}
else if (a[i] > b[j])
{
j++;
}
else
{
commonCount++;
i++; j++;
}
}
return commonCount;
}
int[] str = { 1, 2, 5, 6, 9 ,10,33};
int[] str1 = { 2, 6, 8, 10, 11,9 };
int ii = 0;
foreach (int i in str)
{
foreach (int j in str1)
{
if (i.ToString().Equals(j.ToString()))
{
ii++;
}
}
}
Response.Write(ii);