int num = 0;
cin>>num;
int **ip = new int* [num];
for(int i = 0; i != num;++i)
ip[i] = new int [num];
//----------------------------------赋值
for(int i = 0; i != num; ++i)
for(int j = 0; j!= num; ++j)
ip[i][j] = i;
//----------------------------------输出
for(int i = 0; i != num; ++i)
for(int j = 0; j!= 4; ++j)
cout<<ip[i][j]<<endl;
相关推荐
自动驾驶轨迹规划算法——Apollo Lattice Planner
Apollo Lattice Planner是百度Apollo自动驾驶系统中的一种基于采样的实时轨迹规划算法。其核心思想是在离散化的状态空间中,对终端状态进行采样,并通过多项式曲线连接当前状态与候选终端状态,形成候选轨迹集,最后基于代价函数选择最优轨迹。该算法将车辆可达状态按纵向距离、横向偏移和速度等维度规则离散化,形成"格点"状态空间。 Lattice Planner通过三个主要步骤实现轨迹规划:1)终端状态采样,在规划时域内枚举多种驾驶意图;2)轨迹生成,使用五次多项式连接起点与各终
如何在C/C++中动态分配二维数组
如何在C/C++中动态分配二维数组 在C/C++中动态分配二维数组可以先申请一维的指针数组,然后该数组中的每个指针再申请数组,这样就相当于二维数组了,但是这种方法会导致每行可能不相邻,从而访问效率比较低。如何申请连续的二维数组了?本文将分别三个方面讲解: 一.动态申请列大小固定的二维数组 二.C语言中动态申请连续的二维数组 三.C++语言中动态申请连续的二维数组 一.动态申请列大小固定的二维数组...
rk3568 OpenHarmony4.0如何使用中文输入法
问题:rk3568开发板 OpenHarmony4.0release系统自带输入法kikaInput软件只有英文输入,不含中文输入,不方便。本文基于rk3568开发板 OpenHarmony4.0release移植了laval社区发布的开发者手机中的搜狗输入法(测试版),实现了中文输入,为OpenHarmony4.0release的其他开发板中文输入提供参考。
C++中如何动态分配二维数组
一直对二维数组 动态分配问题比较模糊,今天来终结一下。 我们一般使用二维数组可以直接定义如下: #include using namespace std; int main() { int array[5][5]; } 但是有时候我们不知道数组的维数,C++不允许直接用变量作为维数,所以就要用到动态分配。我们先看看如何动态申请一个一维数组。 int num; int* arr
PyMySQLSaver实战:构建高可靠性的LangGraph状态管理
本文详细介绍了如何使用PyMySQLSaver构建高可靠性的LangGraph状态管理系统。通过检查点机制和MySQL持久化技术,开发者可以确保AI应用在崩溃后从最近状态恢复,支持长时间运行任务和多轮交互。文章包含核心架构解析、生产环境部署指南及实战案例,帮助开发者掌握状态管理的核心技术。
用Python实现一个简单的远程桌面服务端和客户端
本文介绍了一个基于Python的轻量级远程桌面解决方案,针对商业软件在嵌入式系统上的兼容性问题、性能问题和成本问题。系统采用客户端-服务端架构,包含两个通信通道:5000端口传输压缩视频流,5001端口传输控制事件。通过多线程设计、图像压缩(JPEG+zlib)和网络优化(禁用Nagle算法)等技术手段提高性能。服务端实现了高效的屏幕捕获(使用mss库)、图像处理流水线和事件处理逻辑。客户端采用PyQt5构建UI界面,包含视频接收线程以减少主线程负担。该方案具有跨平台、开源免费、轻量级(核心代码不到500行
C++二维数组的动态分配
C++中动态分配一维数组是十分常见的事,但会分配一维数组的人并不一定会分配二维数组。因为我想,不到特殊情况,我们可能很少想过要使用动态分配的二维数组。但不管怎么样,只要你是第一次想试着去分配一个二维数组的时候,你或多或少的会想当然地认为二维数组一定是像这样分配的:int m=2, n=3; int** array2D=new int[m][n];。这不是我们的错,因为写多了int n=3; i
操作系统知识点汇总(王道)
操作系统不论是就业还是升学都是核心的一门课程,对于大部分工科更是必修课程。本文章是对《王道操作系统》所有知识点的总结笔记,以供大家学习以及在备考期间复习使用。让我们一起把知识往脑子里旋好吗!!!......
C++中动态分配二维数组
一直对二维数组 动态分配问题比较模糊,今天来终结一下。 我们一般使用二维数组可以直接定义如下: [cpp] view plain copy #include<iostream> using namespace std; int main() { int array[5][5]; } 但是有时候我们不知道数组的维数,C++不允许直...
MSBlock赋能C2f模块,让目标检测在轻量化与精度间双向突破
在文件夹下新建,将上述MSBlock和C2f_MS类的代码写入其中。这一步是为了让YOLOv8的代码架构能识别我们的自定义模块。
RK3568 OpenHarmony3.2 NFC 驱动适配(PN7150)II
承接上文《RK3568 OpenHarmony3.2 NFC 驱动适配(PN7150)I》,继续PN7150 NFC模块的整体适配。本文主要介绍包括HDI实现层、框架层以及设备适配层的代码修改思路。具体包括vendor_adaptor、hdi_service等;以及foundation下的frameworks、services等。此外还包括相关三方库libnfc-nci在鸿蒙平台的移植和适配。需要注意的是,当前nfc适配只是基于作者手上的RK3568平台以及相关OpenHarmony3.2的代码。
C/C++动态分配二维数组
一:C中动态分配二维数组 (1)内存不连续的分配 #include #include #define M 3 #define N 3 // 这样在同一个数组内是连续分配的,但是实际上是不连续分配的 int main(int argc , char*argv[]) { int i ,j ; int **matric ;
利用Dify构建文档内容的分析对比
本次主要做了一些workflow和Agent的应用实现,供大家参考。主要目的是为了进行两个内部报告文件的内容对比,特别是报告中的各类审批表、申请表、推荐表和流程对比,本地数据通过知识库方式分别加载到两个知识库中,编制工作流针对同一个问题进行知识库检索,之后将查询结果进行合并,再一起提交给LLM进行对比,最终将对比分析结果以markdown方式返回显示。主要包括如何构建知识库,如何设计workflow、如何将工作流发布为工具、如何设计提示词、如何在agent中引入前面发布的工具,最终通过agent实现与用户交
动态分配二维数组 C++
动态分配二维数组 1)采用指针的指针 T** 2)指针的指针指向一片存放指针数组作为行 3)指针数组中每一个元素都指向一个元素数组作为列 例如: int main(){ int h, l; cin >> h >> l; int **ptr; //定义一个 int** 的指针 //分配空间 ptr = new int*[h]; //使其指向一片有 h 个元素的数...
迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)
迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)
深度学习工具包 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');```[](https://bitdeli.com/free "Bitdeli Badge")
1624



被折叠的 条评论
为什么被折叠?



