![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c++
wangfy_
这个作者很懒,什么都没留下…
展开
-
汉诺塔
// 递归的分步思想使问题变得简单:// 将前n-1个盘子,从A(通过C)移动到B// 从A到C移动第n个盘子// 将前n-1个盘子,从B(通过A)移动到C#include <iostream>#include <cstring>using namespace std;void hanoi(int n, string A, string B, string C...原创 2018-04-24 17:51:55 · 170 阅读 · 0 评论 -
C++随机函数 rand()、srand()
rand():rand()是用线性同余法实现的,因此不是真的随机数,但因其周期特别长,故在一定的范围里可看成是随机的。rand()返回一随机数值的范围在0至RAND_MAX 间。RAND_MAX的范围最少是在32767之间(int)。用unsigned int 双字节是65535,四字节是4294967295的整数范围。0~RAND_MAX每个数字被选中的机率是相同的。 用户未设定随机数种...原创 2018-04-24 20:44:04 · 1936 阅读 · 0 评论 -
随机停车
假设某段马路的指定停车区间为 [0,6] ,车长L为2,随机停车 ...#include <iostream>#include <cstdlib> #include <ctime> using namespace std;int L; //车长int parking(int low, int high) { //在low~high间随机停的车的数...原创 2018-04-24 20:55:16 · 662 阅读 · 0 评论 -
C结构体、C++结构体 和 C++类的区别
转自:https://blog.csdn.net/Loving_Forever_/article/details/51483828 先来说说C和C++中结构体的不同a) C语言中的结构体不能为空,否则会报错1>d:\myproject\visual studio 2013\projects\myc++\main.c(71): error C2016: C 要求一个结构或联合至...原创 2018-04-21 14:01:31 · 191 阅读 · 0 评论 -
常用的计算长度函数
.size() int vector<int> G[MAXN]; G[i].size();.length() String srt; str.length();strlen() char a[20]; strlen(a);原创 2018-05-15 12:18:04 · 2982 阅读 · 0 评论 -
《算法笔记》2
// 链表// 创建链表#include <cstdio>#include <cstdio>struct node{ int data; node* next;};node* create(int Array[]) { node *head, *p, *pre; head = new node; head->next = NULL; pre ...原创 2018-05-16 17:11:10 · 163 阅读 · 0 评论