110,545
社区成员
发帖
与我相关
我的任务
分享
数组a={1,2.3.4.5.6.7},数组b={2,5,4},把b数组中与a不相等的显示出来
怎么写呢 ,我写不出来using System;
class a
{
static void Main()
{
Foo();
}
public static void Foo()
{
int[] a={1,2,3,4,5,6};
int[] b={3,4,5};
for(int i=0;i<a.Length-1;i++)
{
for(int j=0;j<b.Length-1;j++)
{
if(a[i]==b[j])
break;
Console.WriteLine( a[i]);
}
}
}
}
public static void Foo()
{
int[] a={1,2,3,4,5,6};
int[] b={3,4,5};
ArrayList list=new ArrayList(b);
for(int i=0;i<a.Length;i++)
{
if(!list.Contains(a[i]))
{
Console.WriteLine(a[i]);
}
}
}
public static void Foo()
{
int[] a={1,2,3,4,5,6};
int[] b={3,4,5};
ArrayList list=new ArrayList(b);
foreach(int n in a)
{
if(!list.Contains(n))
{
Console.WriteLine(n);
}
}
}