static void Main(string[] args)
{
int[] aa = new int[10];
int[] a = new int[10];
int[] b = new int[5];
int i, k = 0, t = 0, e;
Console.WriteLine("请输入数组a的5个数值!");
for (i = 0; i < 5; i++)
{
Console.Write("a[{0}]=", i + 1);
a[i] = Convert.ToInt32(Console.ReadLine());
}
Console.WriteLine("请输入数组b的5个数值!");
for (i = 0; i < 5; i++)
{
Console.Write("b[{0}]=", i + 1);
b[i] = Convert.ToInt32(Console.ReadLine());
}
//删除
Console.WriteLine("请输入要删除的元素:");
e = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("删除后的数组为:");
int aaa = 0;
for (i = 0; i < 5; i++) //以下先去除要删除的元素,结果存入 aa
{
if (a[i] != e)
{
aa[aaa++] = a[i];
}
if (b[i] != e)
{
aa[aaa++] = b[i];
}
}
for (i = 0; i < aa.Length; i++) //以下去除数组相同的元素,结果存入 a
{
aaa = aa[i];
if (aaa != 0)
for (int ii = i+1; ii < aa.Length; ii++)
{ //以下去除数组相同的元素,结果存入
if(aaa == aa[ii])
aa[ii]=0;
}
}
for (i = 0; i < aa.Length; i++)
{
a[i] = 0;
if (aa[i] != 0)
{
a[t++] = aa[i];
}
}
for (i = 0; i < 10; i++)
{
Console.WriteLine("a[{0}]={1}", i, a[i]);
}
}
这样的结果满意吗
解释一下你两个数组是怎么回事