![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C/C++
御坂10358
"Place upon the object held but one great wish."
展开
-
struct_and_sort_and_structSort
cpp/Algorithm/sort 和 利用sort对结构体排序 先说sort cppreference里sort的几种用法:1.// sort using a standard library compare function object std::sort(s.begin(), s.end(), std::greater<int>()); for (auto a : s) { s原创 2017-04-06 22:50:41 · 225 阅读 · 1 评论 -
等差素数数列
蓝桥杯 04/08/2017 标题:等差素数列2,3,5,7,11,13……是素数序列。 类似:7,37,67,97,127,157 这样完全由素数组成的等差数列,叫等差素数数列。 上边的数列公差为30,长度为6。2004年,格林与华人陶哲轩合作证明了:存在任意长度的素数等差数列。 这是数论领域一项惊人的成果!有这一理论为基础,请你借助手中的计算机,满怀信心地搜索:长度为10的等差素数列,其公原创 2017-04-08 15:05:04 · 2455 阅读 · 0 评论 -
图的存储结构---(*链式前向星*)
(写出来仅供随时参考)邻接矩阵 代码引自my_Dijkstratypedef struct ArcCell { int weight; // 邻接矩阵的元素即为图的边的权值 }ArcCell, AdjMatrix[MAX_VERTEX_NUM][MAX_VERTEX_NUM];typedef struct { int vexs[MAX_VERTEX_NUM]; // 存放顶点的数组原创 2017-04-10 23:56:09 · 426 阅读 · 0 评论 -
memset
std::memset Defined in header <cstring> (‘<”>’的转义为<and>) Cppreference void* memset( void* dest, int ch, std::size_t count); Converts the value ch to unsigned char and copies it i原创 2017-04-11 21:09:50 · 370 阅读 · 0 评论 -
C/C++中的结构体
在C中:typedef struct Student{ int a; }Stu; struct Student stu1; Stu stu2; stu1.a = 2; stu2.a = 3;使用typedef后,Stu和struct Student一样,是一种结构体类型,能用来定义变量。在C++中:typedef struct Student{ int原创 2017-12-10 23:48:23 · 141 阅读 · 0 评论 -
C++的格式化输出之小数尾数
本文仅是个人想记录一下C++的某些用法,倘若以后忘了还能复习一下 浮点数的显示精度 浮点数精度的含义取决于输出模式。在默认模式下,它指的是显示的总位数。在定点模式和科学模式下,精度指的是小数点后面的位数。C++的默认精度为6位。 float a = 130, b = 3.1456; cout << a <&l...原创 2018-03-17 14:50:34 · 1266 阅读 · 1 评论 -
C-插入排序、归并排序、快速排序(代码记录)
目的:备忘 以下直接贴代码:#include<stdio.h> #include<stdlib.h>void myswap(int * a, int * b) { int tmp; tmp = *a; *a = *b; *b = tmp; }void insertion_sort(int * Ar, const int low, const int high) {原创 2018-04-14 00:39:04 · 153 阅读 · 0 评论 -
C-Fibonacci123
Fibonacci的三种写法,当N稍大一点时,递归的慢就显出来了。 参数N表示求的是第N项斐波那契数(这里设前两项是0、1) code: #include<stdio.h> long long Fibonacci1(long long n) { long long a = 0, b = 1, c, i; if(n == 1) return a...原创 2018-04-14 10:28:32 · 158 阅读 · 0 评论 -
[MPICH] Matrix Multiplication
Samples : 10 5 5 3 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 1 5 1.1 2 4 2.2 3 3 3.3 4 2 4.4 5 1 5...原创 2018-06-09 22:46:09 · 209 阅读 · 0 评论