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();
            }
  • 相关阅读:
    清除浮动的三种方式
    js控制滚动条默认在底部
    npm 基础命令
    package.json中^,~的区别
    mac 使用iTerm2快捷登录远程服务器
    iterm 分屏切换快捷键与配色设置
    git tag — 标签相关操作
    gulp iconfont
    webpack 3 升级 webpack4 个人笔记
    import * as x from 'xx' 和 import x from 'xx'
  • 原文地址:https://www.cnblogs.com/cxy521/p/1348573.html
Copyright © 2011-2022 走看看