zoukankan      html  css  js  c++  java
  • 20150918集合以及特殊集合

    //查看一个数字在不再数组里面
    int[] aaa = new int[5] { 1, 2, 3, 4, 5 };
    bool ok = aaa.Contains(int.Parse(Console.ReadLine()));
    if (ok)
    {
    Console.WriteLine("you");
    }

    else
    Console.WriteLine("my");

    int count = aaa.Count();//计算元素个数

    //ArrayList a = new ArrayList();
    //for (int i = 0; i < 10; i++)
    //{
    // Console.Write("请输入第{0}个人的成绩:", i + 1);
    // int b = int.Parse(Console.ReadLine());
    // a.Add(b);
    //}
    //a.Sort();//排序 从小到大
    //a.Reverse();//反转

    //stack 正着进 倒着出
    Stack s = new Stack();
    s.Push(3);
    s.Push(5);
    s.Push(7);
    //输出出来为 7 5 3
    foreach (int a in s)
    {
    Console.WriteLine(a);
    }

    int count = s.Count;//个数

    int qu = int.Parse(s.Pop().ToString()); //弹出最后一个元素

    Console.WriteLine(qu);

    s.Clear();//清空集合

    //queue
    Queue b = new Queue();
    b.Enqueue(3);
    b.Enqueue(5);
    b.Enqueue(7);

    foreach (int q in b)
    {
    Console.WriteLine(q);
    }

    b.Clear();//清空集合

    int chu = int.Parse(b.Dequeue().ToString());
    Console.WriteLine(chu);

    //Hashtable 后进后出
    Hashtable a = new Hashtable();
    a.Add(3, "张三");
    a.Add(4, "李四");

    foreach (int b in a.Keys)
    {
    Console.WriteLine(b);
    }

    foreach (string s in a.Values)
    {
    Console.WriteLine(s);
    }

    int count =a.Count; //元素个数

    Console.WriteLine(a[3]); //能单独取

  • 相关阅读:
    微博回调接口
    vue获取微博授权URL
    生成微博授权URL接口
    微博账号注册
    微博三方登录原理讲解
    使用celery异步发送短信
    celery配置与基本使用
    友情链接
    Linux无线网络设置--wpa_supplicant的使用
    wpa_supplicant介绍与使用
  • 原文地址:https://www.cnblogs.com/hz1234/p/4828238.html
Copyright © 2011-2022 走看看