zoukankan      html  css  js  c++  java
  • 级数求和 C# lanmda写法

    #pragma once
    #include "stdafx.h"
    #define MAXK 1e7
    //class AlgoMath {
    //public:
    //	AlgoMath() {}
    //	virtual ~AlgoMath() {}
    //};
    
    //级数求和
    //伪 lanmda 写法 
    //double Series=(double base, int limit, int Constant) => int constant + sigma{ base^i / i | (1 <= i <= 100) };
    //Constant 常数项 , base 底数,limit 极限上界
    double Series(double base, int limit, int Constant) {
    	double sum = 0.0;
    	int i;
    	//limit is 1 to 100
    	for (i = 1; i <= limit; i++) {
    		sum += pow(base, i) / i;
    	}
    	//sum 初值为1
    	sum += Constant;
    	return sum;
    }
    //级数求和,WithTemp
    double SeriesHaveTemp(int Constant, double base, int limit) {
    	double sum = 1.0;
    	double temp = 1;
    	int i;
    	//limit is 1 to 100
    	for (i = 1; i <= limit; i++) {
    		temp = pow(base, i);
    		sum = sum + temp / i;
    	}
    	return sum;
    }
    //void main() {
    //	int i;
    //	clock_t start, end;
    //	double duration;//used to stored top - end
    //	start = clock();
    //	for (i = 0; i < MAXK; i++) {
    //		fun1(1.1, 100);
    //	}
    //	end = clock();
    //	duration = ((double)(end - start)) / CLK_TCK / MAXK;
    //	printf("every method fun1 using average time:%f
    ", duration);
    //
    //	start = clock();
    //	for (i = 0; i < MAXK; i++) {
    //		fun2(1.1, 100);
    //	}
    //	end = clock();
    //	duration = ((double)(end - start)) / CLK_TCK / MAXK;
    //	printf("every method fun2 using average time:%f
    ", duration);
    //
    //}
    
    //C#级数求和,
    //伪 lanmda 写法 
    //double Series=(double base, int limit, int Constant) => int constant + sigma{ base^i / i | (1 <= i <= 100) };
    //Constant 常数项 , base 底数,limit 极限上界
    //double Series(double baseX, int limit, int Constant) {
    //    double sum = 0.0;
    //    int i;
    //    //limit is 1 to 100
    //    for (i = 1; i <= limit; i++) {
    //        sum += Math.Pow(baseX, i) / i;
    //    }
    //    //sum 初值为1
    //    sum += Constant;
    //    return sum;
    //}
    
    ////C# lanmda mySeries写法
    ////级数求和 C#真lanmda写法
    ////Constant 常数项, base 底数,limit 极限上界
    //double baseX;
    //int limit;
    //int Constant;
    //delegate double del(double baseX, int limit, int Constant);
    //del mySeries = (baseX, limit, Constant) = > {
    //	double sum = 0.0;
    //	int i;
    //	// limit is 1 to 100
    //	for (i = 1; i <= limit; i++) {
    //		sum += Math.Pow(baseX, i) / i;
    //	}
    //	//sum 初值为1
    //	sum += Constant;
    //	return sum;
    //};
    

      

  • 相关阅读:
    linux 下监控进程流量情况命令 NetHogs
    tensorflow学习官网地址
    zabbix 报表
    zabbix性能优化等
    awk输出匹配内容的所在列数
    zabbix api支持的数据类型
    ss命令能识别的TCP状态的关键字
    数据分析初识、Anaconda安装、Juypyter notebook配置与快捷键
    Flask框架(五)之SQLAlchemy
    Flask框架(四)之信号
  • 原文地址:https://www.cnblogs.com/blacop/p/6602720.html
Copyright © 2011-2022 走看看