![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法和竞赛题等
创一个算法的专栏,平时如果遇到一些常用算法或者一些算法比赛的题目,可以把他们发到这里面
hacker_G
the F world
展开
-
C++动态生成二维和三维数组
最近在编写一些C++小程序的时候用到二维和三维数组,看了很多博客关于动态生成二维和三维数组的方法,写的非常好,但是一大串的for循环还是不想写,为了偷下懒给自己写几个函数留着以后写其他程序的时候直接用。今天看书的时候看到了C++的类模板,正好借这个编一个函数生成二维和三维数组。#include <iostream>using namespace std;template &...原创 2018-08-07 21:50:43 · 876 阅读 · 0 评论 -
C/C++ 保留N位小数
保留N位小数方法一:使用fixed和setprecision#include <iostream>#include <iomanip> //需要包含此头文件using namespace std;int main(){ double x=3.1415926; int N=3; cout <<fixed<<s...原创 2018-08-08 11:53:46 · 5548 阅读 · 0 评论 -
C++寻找数组最大值和最小值
C++里面有好多自带函数可以直接用,比如寻找数组中的最大最小值其实是有函数的,如下#include <iostream>using namespace std;#include <algorithm>int main() { int n; cin >> n; int *p = new int[n]; for (int i = 0; i&l...原创 2018-08-13 13:52:42 · 30258 阅读 · 1 评论