![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法笔记胡凡
文章平均质量分 85
dream or nightmare
分享资源,总结知识,一起进步。
展开
-
第四章 入门篇(2) 算法初步
1012 The Best Rank (25 分)To evaluate the performance of our first year CS majored students, we consider their grades of three courses only:C- C Programming Language,M- Mathematics (Calculus or Linear Algrbra), andE- English. At the mean time, we en...原创 2021-08-20 09:48:15 · 902 阅读 · 0 评论 -
算法笔记 第六章第七章第八章
第六章 标准模板库A1039. Course List for StudentA1047. Student List for Course使用map会超时#include <iostream>#include <vector>#include <algorithm>#include <string.h>using namespace std;char name[40010][5];vector<int> co.原创 2021-08-20 09:43:01 · 595 阅读 · 0 评论 -
算法笔记.胡凡 第11章 动态规划专题
11.1 动态规划的递归写法和递推写法11.1.1 动态规划的递归写法以斐波那契数列为例,递归代码为int F(int n) { if (n == 0 || n == 1) return 1; else return F(n-1) + F(n-2);}这个递归涉及太多的重复计算,为了避免重复计算,可以开一个一维数组dp,用来保存已经计算过的结果。dp[n] = -1表示F(n)当前还没有被计算过。int dp[MAXV];int F(int n) { if原创 2021-08-16 10:37:10 · 341 阅读 · 0 评论 -
算法笔记.胡凡 第九章 二叉树
9.1 树与二叉树二叉树的存储struct node { typename data; node* lchild; node* rchild;};新建节点node* newNode(int v) { node* Node = new node; Node->data = v; Node->lchild = Node->rchild = NULL; return Node;}二叉树的查找void sea原创 2021-08-13 14:49:36 · 291 阅读 · 0 评论 -
算法笔记.胡凡 第七章 数据结构专题 & 第八章 搜索专题
7.3 链表处理7.3.1 链表概念struct node { typename data;//数据域 node* next;//指针域};链表可以分为带头结点的和不带头结点的链表。7.3.2 为链表节点分配内存空间1. malloc函数typename* p = (typename*) malloc(sizeof(typename));int* p = (int*) malloc(sizeof(int));int* p = (int*) malloc(10原创 2021-08-12 09:30:04 · 231 阅读 · 0 评论 -
算法笔记.胡凡 第6章 C++标准模板库(STL)介绍
6.1 vector常见用法详解6.1.1.vector定义vector<int> name;6.1.2.vector容器元素访问(1) 下标:v[0](2)迭代器vector<int> vi;vector<int>::iterator it = vi.begin();for(int i = 0; i < 5; i++) { cout<<*(it + i)<<endl;}for(vector&..原创 2021-08-11 10:35:35 · 267 阅读 · 0 评论 -
算法笔记.胡凡 第五章 数学问题
5.1 简单数学【PAT A1069】For any 4-digit integer except the ones with all the digits being the same, if we sort the digits in non-increasing order first, and then in non-decreasing order, a new number can be obtained by taking the second number from the firs原创 2021-08-10 19:05:43 · 323 阅读 · 0 评论 -
算法笔记胡凡 第3章 入门篇
3.5进制转换P进制的数转换为Q进制的数,分为两步:①将P进制的数x转换为十进制数y②将十进制数y转换为Q进制数z除基取余法[PAT B1022] D进制的A+B输入两个非负 10 进制整数A和B(≤230−1),输出A+B的D(1<D≤10)进制数。输入格式:输入在一行中依次给出 3 个整数A、B和D。输出格式:输出A+B的D进制数。输入样例:123 456 8输出样例:1103#include...原创 2021-08-10 14:47:57 · 284 阅读 · 0 评论