zoukankan      html  css  js  c++  java
  • 两数组相比筛选数据

    static void Main(string[] args)
            {
               
    int[] a = new int[] { 2, 4, 5, 7, 8 };
               
    int[] b = new int[] { 9, 4, 5, 6, 7, 8 };
               
    //不要用数组 老出错
                  ArrayList alist = new ArrayList(a);
                  ArrayList blist
    = new ArrayList(b);
                ArrayList same
    = new ArrayList();
                ArrayList aDif
    = new ArrayList();
                ArrayList bDif
    = new ArrayList();

              
    foreach(object o in alist)
               {
                  
    if (blist.Contains(o))
                   {
                       same.Add(o);
                   }
                  
    else {
                       aDif.Add(o);
                   }
               }
               
               
    foreach (object o in blist)
               {
                  
    if (!same.Contains(o))
                   {
                       bDif.Add(o);
                   }
               }


                Console.WriteLine(
    "相同的");
               
    foreach (Object o in same)
                    Console.Write(
    "   {0}", o);
                Console.WriteLine();
                Console.WriteLine(
    "a中特有的");
               
    foreach (Object o in aDif)
                    Console.Write(
    "   {0}", o);
                Console.WriteLine();
                Console.WriteLine(
    "b中特有的");
               
    foreach (Object o in bDif)
                    Console.Write(
    "   {0}", o);

                Console.Read();
            }
  • 相关阅读:
    概率论
    英语单词每日学习
    网上学习新课程--使用开发板动手进行uboot、内核以及驱动移植
    csdn专家主页
    material of DeepLearning
    I2C协议
    SVN appears to be part of a Subversion 问题心得
    @清晰掉 各种类型32位与64位下各类型长度对比
    超级方便的linux命令手册
    HTTP协议详解(转)
  • 原文地址:https://www.cnblogs.com/cxy521/p/1348573.html
Copyright © 2011-2022 走看看