pat
文章平均质量分 87
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 · 924 阅读 · 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 · 596 阅读 · 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 · 346 阅读 · 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 · 296 阅读 · 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 · 233 阅读 · 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 · 287 阅读 · 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 · 328 阅读 · 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 · 285 阅读 · 0 评论 -
算法笔记.胡凡 第四章 算法初步
4.1 排序4.1.1 选择排序void selectSort(int A[], int n) { for (int i = 0; i < n; i++) { int k = i; for (int j = i + 1; j < n; j ++) { if (A[j] < A[k]) { k = j; } } if (k != i原创 2021-08-10 14:46:35 · 321 阅读 · 0 评论 -
pat c/c++准备知识篇
1.入门知识1. int 类型的大致范围在-2 x~2 x, long long的类型在-9 x~ 9 x之间,float实际精度6~7位,double精度15~16位2.0~9、A~Z、a~z ASCII码分别为48~57、65~90、97~122。空格ASCII码为323. true输出为1,强制类型转换为(新类型名)变量名4. 除了%c外,scanf对格式符(%d)的输入是以空白符为结束判断标志的。字符串%s读入以空格和换行符为读入结束的标志。数据类型 格式...原创 2021-08-10 09:44:55 · 550 阅读 · 0 评论