第八周项目一任务*1*成员函数

YOLO11改进|注意力机制篇|引入MLCA轻量级注意力机制 YOLO11中添加MLCA轻量级注意力机制 阅读详情
  1. /*   
  2. * 程序的版权和版本声明部分   
  3. * Copyright (c)2012, 烟台大学计算机学院学生   
  4. * All rightsreserved.   
  5. * 文件名称: 1.cpp   
  6. * 作者:王俊  
  7. * 完成日期: 2013年 4 月 19 日   
  8. * 版本号: v1.0   
  9. * 输入描述:无   
  10. * 问题描述:   
  11. * 程序输出:   
  12. */      
  13. 代码输出:
  14. #include <iostream>
    
    using namespace std;
    
    class Complex
    {public:
    	Complex(){real=0;imag=0;}
    	Complex(double r,double i){real=r;imag=i;}
    	Complex operator+(Complex &c2);
    	Complex operator-(Complex &c2);
    	Complex operator*(Complex &c2);
    	Complex operator/(Complex &c2);
    	void display();
     private:
    	double real;
    	double imag;
    };
    //下面定义成员函数
     Complex Complex::operator+(Complex &c2)
        {
        Complex c;
        c.real=real+c2.real;
        c.imag=imag+c2.imag;
        return c;
        }
    Complex Complex:: operator-(Complex &c2)
    	{
    	Complex c;
        c.real=real-c2.real;
        c.imag=imag-c2.imag;
        return c;
    	}
    Complex Complex:: operator*(Complex &c2)
    	{
    	Complex c;
        c.real=real*c2.real;
        c.imag=imag*c2.imag;
        return c;
    	}
    Complex Complex:: operator/(Complex &c2)
    	{
    	Complex c;
        c.real=real/c2.real;
        c.imag=imag/c2.imag;
        return c;
    	}
    void Complex::  display()
    {
    cout<<"("<<real<<","<<imag<<")"<<endl;
    }
    //下面是测试函数
    int main()
    {
    	Complex c1(3,4),c2(5,-10),c3;
    	cout<<"c1=";
    	c1.display();
    	cout<<"c2=";
    	c2.display();
    	c3=c1+c2;
    	cout<<"c1+c2=";
    	c3.display();
    	c3=c1-c2;
    	cout<<"c1-c2=";
    	c3.display();
    	c3=c1*c2;
    	cout<<"c1*c2=";
    	c3.display();
    	c3=c1/c2;
    	cout<<"c1/c2=";
    	c3.display();
    	return 0;
    }
    

    运行结果:
《派出你的AI同事:WorkBuddy案例实战》067:按行业分类的案例索引 按行业分类的案例索引 —— 《派出你的AI同事:WorkBuddy案例实战》系列文章,配图已统一为规范示意图。 阅读详情

相关推荐

别再对着ACF/PACF图发懵了!用R语言实战教你一眼分清AR、MA和ARMA模型

本文通过R语言实战详细解析了时间序列分析中AR、MA和ARMA模型的特征图识别技巧。重点讲解了如何通过ACF和PACF图的截尾与拖尾特征快速判断模型类型,帮助数据分析师建立从图形到模型的直觉映射,提升时间序列分析的效率和准确性。

weixin_28706923的博客 356

第八周项目一:用类的成员函数完成运算符的重载(任务一)

/* * 程序的版权和版本声明部分 * Copyright (c)2013, 烟台大学计算机学院学生 * All rightsreserved. * 文件名称: object.cpp * 作者:李蒙 * 完成日期: 2013年04月14日 * 版本号: v1.0 * 输入描述:无 * 问题描述:无 * 程序输出:无 */

zylmtz2012的专栏 2086

SHAP图全解析:从理论到实践,教你如何读懂和优化模型特征

本文全面解析SHAP图,从博弈论基础到实战应用,指导读者如何解读和利用SHAP值优化机器学习模型。通过详解特征重要性条形图、小提琴图、依赖图及决策图等关键可视化工具,帮助数据科学家精准诊断模型、识别特征交互,并将洞见转化为特征工程与模型调试的实际行动,有效提升模型可解释性与性能。

svm4gardener的博客 188

第八周任务1

/* (程序头部注释开始)  * 程序的版权和版本声明部分  * Copyright (c) 2011, 烟台大学计算机学院学生   * All rights reserved.  * 文件名称:                                * 作    者:   高中亚                 * 完成日期:   2012   年  4 月 89 日  *

Richard_zy的专栏 850

Howland电流源电路:从理论到实践的深度解析与优化策略

本文深度解析了Howland电流源电路的工作原理,从经典四电阻架构的“虚短”“虚断”分析,到其实现宽带恒流输出的理论优势。重点剖析了实践中因电阻精度、运放参数及PCB布局导致的性能瓶颈,并提供了引入第五电阻、优化运放选型等关键优化策略,旨在将输出阻抗从kΩ级提升至MΩ级,以满足精密测量与传感器驱动等应用需求。

weixin_29243063的博客 441

微信小程序云开发 - 实现商家转账到零钱(微信企业付款到零钱) V3功能流程及完整实例代码,过微信云开发的云函数实现企业付款到零钱(提供详细示例源码纯云函数实现,证书、密钥、签名等各种常见问题解决方案

企业付款到零钱(微信小程序提现功能,提现到零钱)微信小程序-云函数实现微信企业付款到零钱功能,实现微信商户号中的企业付款到零钱的功能,微信小程序+云开发+商家转账至零钱+微信小程序用户提现,使用云开发环境的云函数实现微信小程序的支付功能,微信小程序实现微信企业付款到零钱功能的流程,V3 V2基于微信云开发的商家转账至零钱,小程序云函数企业付款到零钱功能实现,云开发实现微信商户支付企业付款到零钱功能,不用服务器纯云函数实现,详细示例代码demo教程,API证书错误,转账不到账怎么办,密钥生成有误,转账失败,有

🏆 前端领域优质创作者 1万+

《第八周实验报告任务1》

/* (程序头部注释开始) * 程序的版权和版本声明部分 * Copyright (c) 2011, 烟台大学计算机学院学生 * All rights reserved. * 文件名称:    复数类中的运算符重载                         * 作    者:       刘江波                       * 完成日期:    2012

JiangBo_Liu 博客 779

BART non-Cartesian 重建:并行成像 压缩感知

本文主要使用并行成像和压缩感知方法实现non-Cartesian MRI 数据的重建。

张哥频道:电生理信号和磁共振成像 1181

第八周任务一1

(程序头部注释开始) * 程序的版权和版本声明部分 * Copyright (c) 2011, 烟台大学计算机学院学生 * All rights reserved * 文件名称: * 作 者: 张艳明 * 完成日期: 2012 年 4 月 9日 版 本 号: V1.0

mingmingbang666的专栏 334

YOLOP v2!YOLOv7结合YOLOP的多任务版本 更好、更快、更强

YOLOP v2!YOLOv7结合YOLOP的多任务版本 更好、更快、更强

jacke121的专栏 2705

Xilinx系ZYNQ学习笔记(一)Vivado使用说明

vivado使用学习

贾saisai的博客 1873

第八周 项目一 (1) 实现复数类中的运算符重载 成员函数

问题及代码:/* * Copyright (c) 2014, 烟台大学计算机学院 * All rights reserved. * 文件名称:test.cpp * 作 者:宋健 * 完成日期:2015年 4月 23日 * 版 本 号:v1.0 * * 问题描述: 请用类的成员函数,定义复数类重载运算符+、-、*、/,使之能用于复数的加减乘除 * 程序输入: * 程

songjian19960721的专栏 439

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

第八周实验报告1——成员函数

/* (程序头部注释开始) * 程序的版权和版本声明部分 * Copyright (c) 2011, 烟台大学计算机学院学生 * All rights reserved. * 文件名称: Student.cpp * 作 者: 计114-4 刘柏蔚 * 完成日期: 2012年 4 月 9

刘柏蔚_Cherry 581

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

第八周任务一(1)

韩云龙         47088270       四月十号   #include using namespace std; class Complex { public:  Complex(){real=0;imag=0;}  Complex(double r,double i){real=r;imag=i;}  Complex operator+(Complex &c2);

h_a_n的专栏 938

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

第八周实验报告(任务1-方案1)

程序头部注释开始 * 程序的版权和版本声明部分 * Copyright (c) 2011, 烟台大学计算机学院学生 * All rights reserved. * 文件名称:  用类的成员函数完成运算符的重载 * 作    者:     郭广建                        * 完成日期:  2012年    04  月   10    日 * 版 本 号:

guoguangjian2011的专栏 826

第八周任务一

#include using namespace std; class Complex { public: Complex(){real=0;imag=0;} Complex(double r,double i){real=r;imag=i;} Complex operator+(Complex &c2); Complex operator-(Complex &c2)

dongbaowen的专栏 818

第八周任务-项目一(任务一成员函数的运算符重载)

/* * 程序的版权和版本声明部分 * Copyright (c)2012, 烟台大学计算机学院学生 * All rightsreserved. * 文件名称: object.cpp * 作者:王锴英 * 完成日期: 2013年4 月19 日 * 版本号: v1.0 * 输入描述:无 * 问题描述:运算符重载 * 程序输出: */ #include using nam

RSwky1220的专栏 991

第八周上级任务

#include using namespace std; class Complex //声明类Complex {public: Complex(){real=0;imag=0;} Complex(double r,double i){real=r;imag=i;} friend Complex operator+(Complex &c1,Comp

liuweili2012的专栏 625

第八周项目一 1 用类的成员函数实现复数类中的运算符重载

/* *Copyright (c)2014,烟台大学计算机与控制工程学院 *All rights reserved. *文件名称:test.cpp *作 者:徐洪祥 *完成日期:2015年4月29日 *版 本 号:v1.0 * * 问题描述:用类的成员函数,定义复数类重载运算符+、—、*、/,使之能用于复数的加减乘除。 * 输入描述: * 程序输出: */ #incl

幸福花落泪的专栏 499

第八周任务(一)

* (程序头部注释开始)       * 程序的版权和版本声明部分          * Copyright (c) 2011, 烟台大学计算机学院学生          * All rights reserved.          * 文件名称:实现复述类中的运算符的重载        * 作 者:刘洋         * 完成日期: 2011年 4月 9日

bfc911的专栏 887

第八周 任务一 方案一

/* 实验内容:实现复数类中的运算符重载定义一个复数类重载运算符+、-、*、/,使之能用于复数的加减乘除。 * 程序的版权和版本声明部分 * Copyright (c) 2011, 烟台大学计算机学院学生 * All rights reserved. * 文件名称: 实现复数类中的运算符重载 * 作 者:

yd小晨的专栏 453

第八周项目一任务一

#include using namespace std; class Complex{ public: Complex(){real=0;imag=0;} Complex(double r,double i){real=r;imag=i;} Complex operator+(Complex &c2); Complex operator-(Complex &

御风的专栏 938

第八周项目一

*/ * Copyright (c) 2011, 烟台大学计算机学院 * All rights reserved. * 作 者: 孙培培 * 完成日期:2013 年 4月22日 * 版 本 号:v1.0 * * 输入描述:略 问题描述: * 程序输出:见下 * 问题分析: 算法设计:略 *///【项目1】实现复数类中的运算符重载 //

sunpeipei220的专栏 810

第八周任务一:运算符重载

/* (程序头部注释开始) * 程序的版权和版本声明部分 * Copyright (c) 2011, 烟台大学计算机学院学生 * All rights reserved. * 文件名称: 实现复数类中的运算符重载 * 作 者: 田庆 * 完成日期: 2012 年

sdtianqing的专栏 618

第八周*【任务1】实现复数类中的运算符重载

/*【任务1】实现复数类中的运算符重载 定义一个复数类重载运算符+、-、*、/,使之能用于复数的加减乘除。 (1)方案一:请用类的成员函数完成运算符的重载;*/ #include using namespace std; class Complex { public: Complex(){real=0;imag=0;} Complex(double r,double

liucuanfeng的专栏 1465

第八周项目一--用类的成员函数实现复数中的运算符重载

问题及代码: /* *All rights reserved. *文件名称:test.cpp *作 者:尚 月 *完成日期:2015年 04 月 29 日 *版本号:V1.0 * *问题描述:用类的成员函数,定义复数类重载运算+,-,*,/,使之能用于复数的加减乘除 *输入描述:无 *程序输出:按要求输出 */ #include #inclu

shangyue025的专栏 645
上一篇: 第七周2成员,友元,一般函数的区别
下一篇: 第八周一(2)友元
sdwangjun
博客等级 码龄14年 35粉丝 116原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值