zoukankan      html  css  js  c++  java
  • MC 自己平均

    using System;
    using System.Drawing;
    using System.Linq;
    using System.Collections;
     
    namespace PowerLanguage
    {
        namespace Function
        {
            public class MyAvg
            {
     
                public static double Avg(ArrayList list,int length)
                {
     
                    if(list.Count < length ) return 0.0 ;
     
                    double all = 0.0 ;
                    for(int i = list.Count - length ; i< list.Count; i++)
                    {
                        all += (Double)list[i];
     
     
                    }
                    if(list.Count >0)
     
                        {
                            return all/length;
                        }
     
     
     
     
                    return 0.0 ;
                }
     
     public static ArrayList ma(ArrayList price, int length,int limit)
            {
     
                if (price.Count < length) return null;
     
                if (length + limit-1 > price.Count) return null;
     
     
                ArrayList temparray = new ArrayList();
     
                for (int i = 0; i < length+limit-1; i++)
                {
     
                    if (i < length - 1) continue;
     
                    double temp = 0;
     
                    for (int j = i; j > i - length; j--)
                    {
     
                        temp += (double)price[j];
     
                    }
     
                    temparray.Add(temp / length);
                    Console.WriteLine("---------------------" + temp);
                }
     
     
     
     
     
                return temparray;
            }
     
     
     
            }
        }
    }
  • 相关阅读:
    刻舟求剑,
    录制时间是不准确的,
    HIV T2
    DNA RNA
    洛谷 P1428 小鱼比可爱
    Codevs 1081 线段树练习2
    Codevs 1080 线段树联系
    Tarjan算法
    Codevs 2611 观光旅游
    洛谷 1865 A%B问题
  • 原文地址:https://www.cnblogs.com/aliblogs/p/5493802.html
Copyright © 2011-2022 走看看