- 博客(23)
- 收藏
- 关注
原创 机试题目2011-2019
机试题目汇总数学/简单模拟:?卡特兰数2019.3:难-直接上公式:相隔天数2019.1:简单-日期处理求众数2018.1:简单-用map存储直接排序或数组存储后再排序字符串:解一元一次2018.2:难-写函数dp动态规划:最大连续子列和2019.2...
2020-05-04 20:24:41
301
原创 100000608 - 《算法笔记》8.1小节——搜索专题->深度优先搜索(DFS)
《算法笔记》8.1小节——搜索专题->深度优先搜索(DFS)5972 Problem A 【递归入门】全排列#include <stdio.h>const int maxn = 10000;int a[maxn];bool flag[maxn] = { false };void combine(int cnt,int n) { if (cnt == n) { ...
2020-05-03 00:04:30
257
原创 100000606 - 《算法笔记》7.2小节——数据结构专题(1)->队列的应用
《算法笔记》7.2小节——数据结构专题(1)->队列的应用1863 Problem A C语言-数字交换#include <stdio.h>#include<algorithm>using namespace std;int main() { int que[11]; for (int i = 0; i < 10; i++) { scanf(...
2020-05-01 19:43:26
211
原创 100000605 - 《算法笔记》7.1小节——数据结构专题(1)->栈的应用
《算法笔记》7.1小节——数据结构专题(1)->栈的应用1918 Problem A 简单计算器#include <iostream>#include <stdio.h>#include <stack>#include <queue>#include <string>#include <map>#incl...
2020-05-01 19:31:16
174
原创 100000598 - 《算法笔记》6.3小节——C++标准模板库(STL)介绍->string的常见用法详解
《算法笔记》6.3小节——C++标准模板库(STL)介绍->string的常见用法详解1983 Problem A 字符串处理
2020-04-28 21:02:47
230
原创 100000597 - 《算法笔记》6.2小节——C++标准模板库(STL)介绍->set的常见用法详解
《算法笔记》6.2小节——C++标准模板库(STL)介绍->set的常见用法详解6126 Problem A Set Similarity (25)
2020-04-27 21:19:35
228
原创 100000596 - 《算法笔记》6.1小节——C++标准模板库(STL)介绍->vector的常见用法详解
《算法笔记》6.1小节——C++标准模板库(STL)介绍->vector的常见用法详解1/头文件#include <vector>using namespace std;2、定义vector <int> stu;vector <int> stu[20];vector <vector<int> > stu;3、访问...
2020-04-27 12:55:11
261
原创 100000584 - 《算法笔记》4.4小节——算法初步->贪心
《算法笔记》4.4小节——算法初步->贪心用局部最优推断全局最优贪心算法使用的问题一定满足最优子结构性质,即一个问题的最优解可以由其子问题的最优解有效构造并不是所有问题都适用贪心算法1、简单贪心PTA B1020 月饼 (25分)#include <cstdio>#include <algorithm>using namespace std;str...
2020-04-25 18:12:00
253
原创 100000583 - 《算法笔记》4.3小节——算法初步->递归
《算法笔记》4.3小节——算法初步->递归先考虑边界,再考虑递归1、全排列#include <cstdio>const int maxn = 11;int p[maxn], hashTable[maxn] = { false };//从index到n的全排列void generateP(int index,int n) { if (index == n + 1)...
2020-04-06 10:09:14
362
1
原创 100000582 - 《算法笔记》4.2小节——算法初步->哈希
《算法笔记》4.2小节——算法初步->哈希1、直接把输入的数(<10^5)作为数组的下表,来对这个书的性质进行统计(用空间换时间),复杂度由O(n)减到O(1)例1:统计M个数是否出现在N个数中#include <stdio.h>const int maxn = 100010;bool hashTable[maxn] = { false };int main(...
2020-03-31 15:42:27
336
原创 100000581 - 《算法笔记》4.1小节——算法初步->排序
《算法笔记》4.1小节——算法初步->排序冒泡排序int bubblesort() { int num; scanf("%d", &num); int a[100]; for (int i = 0; i < num; i++) scanf("%d", &a[i]); for (int i = 1; i < num; i++) { for (i...
2020-03-30 17:41:12
211
原创 100000580 - 《算法笔记》3.6小节——入门模拟->字符串处理
《算法笔记》3.6小节——入门模拟->字符串处理1785 Problem A 字符串连接#include<cstdio>#include<cstring>int main() { char a[200], b[100]; while (scanf("%s %s", &a, &b) != EOF) { int lena = 0 , le...
2020-03-29 16:39:50
243
原创 100000579 - 《算法笔记》3.5小节——入门模拟->进制转换
《算法笔记》3.5小节——入门模拟->进制转换1941 Problem A 又一版 A+B#include <stdio.h>#include <string.h>int main() { int m; long long a, b; while (scanf("%d", &m) != EOF) { if (m == 0) break; ...
2020-03-22 01:09:03
168
原创 100000578 - 《算法笔记》3.4小节——入门模拟->日期处理
《算法笔记》3.4小节——入门模拟->日期处理1928 Problem A 日期差值经典的日期差值模拟注意平年闰年的差别,两个时间点之间的差值用较小的时间不断累加来追上较大的时间,累加时注意到达其上时递进#include <stdio.h>#include <string.h>#include <algorithm>using namespa...
2020-03-21 17:00:58
227
原创 100000577 - 《算法笔记》3.3小节——入门模拟->图形输出
《算法笔记》3.3小节——入门模拟->图形输出PTA B1036 跟奥巴马一起编程 (15分)#include <stdio.h>#include <string.h>int main() { int row, col; char a; scanf("%d %c", &col, &a); if (col % 2 == 0) ro...
2020-03-18 08:58:07
248
原创 100000576 - 《算法笔记》3.2小节——入门模拟->查找元素
《算法笔记》3.2小节——入门模拟->查找元素1932 Problem A 统计同成绩学生人数#include <stdio.h>#include <string.h>int main() { int N = 0; scanf("%d", &N); while (N!=0) { int a[1000] = { 0 }, score = 0,...
2020-03-14 23:54:25
241
原创 100000575 - 《算法笔记》3.1小节——入门模拟->简单模拟
《算法笔记》3.1小节——入门模拟->简单模拟PAT B1001 害死人不偿命的(3n+1)猜想#include <stdio.h>int main() { int n = 0, num = 0; scanf("%d", &n); while (n != 1) { if (n % 2 == 0) n /= 2; else n = (3*n + 1)...
2020-03-04 17:36:23
443
原创 100000574 - 《算法笔记》2.10小节——C/C++快速入门->黑盒测试
《算法笔记》2.10小节——C/C++快速入门->黑盒测试1000 Problem A A+B 输入输出练习I//while...EOF型 多点输入测试#include <stdio.h>//#include<iostream>//using namespace std;int main() { int a, b; //while (scanf("%...
2020-03-01 20:03:37
221
原创 100000572 - 《算法笔记》2.8小节——C/C++快速入门->结构体(struct)的使用
《算法笔记》2.8小节——C/C++快速入门->结构体(struct)的使用1303 Problem A C语言11.1#include <cstdio>#include <cstring>int main() { struct person { char name[20]; int count; }leader[3] = { "Li", 0, ...
2020-03-01 17:24:47
295
原创 100000571 《算法笔记》2.7小节——C/C++快速入门->指针
《算法笔记》2.7小节——C/C++快速入门->指针1269 Problem A C语言10.1#include <stdio.h>#include <string.h>int main() { int a, b; int *p1=&a, *p2=&b; scanf("%d %d", p1,p2); if (*p1 > *p2...
2020-02-29 19:56:42
343
原创 100000570 《算法笔记》2.6小节——C/C++快速入门->函数
《算法笔记》2.6小节——C/C++快速入门->函数26339 Problem A 习题7-5 字符串逆序存放#include <stdio.h>#include <string.h>void trans_print(char a[]);int main() { char a[10]; scanf("%s", a); trans_print(a);...
2020-02-29 11:42:34
234
原创 100000569 - 《算法笔记》2.5小节——C/C++快速入门->数组
《算法笔记》2.5小节——C/C++快速入门->数组26039 Problem A 习题6-4 有序插入#include <stdio.h>int main() { int a[10]; for (int i = 0; i < 10; i++) { scanf("%d", &a[i]); } int temp = a[9]; int j; f...
2020-02-27 17:41:33
203
原创 100000568 - 《算法笔记》2.4小节——C/C++快速入门->循环结构
100000568 - 《算法笔记》2.4小节——C/C++快速入门->循环结构问题 I: 习题5-10 分数序列求和#include <stdio.h>int main() { int j, i; int a[20] = { 1,1 }; double b[20] = { 0 }; double sum = 0.0; for (i = 0, j = 2; i ...
2020-02-25 12:26:59
191
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人