常用代码模板模板
代码模板及学习笔记
卓卓世界
卓卓世界
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
常用代码模板系列文章目录
文章目录0、文件输入1、高精度加2、高精度乘3、快读 0、文件输入 freopen("C:\\Users\\30414\\Desktop\\洛谷新生\\input.in","r",stdin); 1、高精度加 #include <cstring> #include <iostream> using namespace std; char aa[64], bb[64], cc[64]; int a[64], b[64], c[64]; int ans[64 * 3]; int add原创 2021-11-30 15:51:39 · 175 阅读 · 0 评论
-
18_最长公共子串
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> using namespace std; const int MAXI = 1e4; int dp[MAXI][MAXI]; int LCS(char* s1, char* s2) { int ans = 0; for (int i = 1; i <= strlen(s1); i++原创 2021-12-11 18:55:08 · 292 阅读 · 0 评论 -
17_最长公共子序列
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> using namespace std; const int MAXI = 1e4; int dp[MAXI][MAXI]; void LCS(char* s1, char* s2) { for (int i = 1; i <= strlen(s1); i++) for (i原创 2021-12-11 17:04:31 · 171 阅读 · 0 评论 -
16_归并排序
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> using namespace std; const int MAXI = 1e4; void merge(int* array, int low, int mid, int high) { if (low >= high) { return; } int*原创 2021-12-11 16:21:03 · 101 阅读 · 0 评论 -
15_二分查找
#include <stdio.h> #include <stdlib.h> const int MAXN = 1e4; int array[MAXN]; int binarySearch(int *arr, int key, int length) { int left = 0; //左边界 int right = length - 1; //右边界 while (left <= right) { int middle = (left + right) / 2;原创 2021-12-07 21:34:49 · 110 阅读 · 0 评论 -
14_斐波那契数列的非递归写法
#include <stdio.h> #include <stdlib.h> typedef long long ll; const int MAXN = 1e4; ll a[MAXN]; void get_Fibonacci(ll n) { for (int i = 0; i < MAXN; i++) { if (i <= 1) a[i] = 1; else a[i] = a[i - 1] + a[i - 2]; } } int main() { ge原创 2021-12-07 16:39:08 · 268 阅读 · 0 评论 -
13_斐波那契数列的递归写法
#include <stdio.h> #include <stdlib.h> typedef long long ll; ll Fibonacci(ll n) { if (n <= 1) return 1; return Fibonacci(n - 1) + Fibonacci(n - 2); } int main() { ll n; printf("你要斐波那契数列的第几项?\n"); scanf("%lld", &n); printf("%lld",原创 2021-12-07 16:34:40 · 140 阅读 · 0 评论 -
12_Hanio(汉诺塔)
#include <stdio.h> #include <stdlib.h> void move(char no, char from, char to) { printf("将 %d 号盘子从 %c 移动到 %c\n", no, from, to); } void hanoi(int n, char p1, char p2, char p3) { if (n == 1) {//只有一层的情况 move(n, p1, p3); return; } //将p3看作中原创 2021-12-07 16:21:06 · 142 阅读 · 0 评论 -
11_普通快速排序
#include <stdio.h> #include <stdlib.h> #define MAXZISE 100 #define ElemType int int Partition(ElemType A[], int low, int high) { ElemType pivot = A[low]; while (low < high) { while (low < high && A[high] >= piv原创 2021-12-05 10:48:15 · 432 阅读 · 0 评论 -
10_优化KMP算法
/** * @Author: 郑潮安yyds * @Time: 2021/12/2 22:15. * @Filename: Kmp.cpp * @Software: CLion */ #include <iostream> #include <cstring> #define MaxSize 1000 using namespace std; typedef struct { char data[MaxSize]; int length; /原创 2021-12-03 14:41:04 · 134 阅读 · 0 评论 -
9_普通KMP算法
/** * @Author: 郑潮安yyds * @Time: 2021/12/2 22:15. * @Filename: Kmp.cpp * @Software: CLion */ #include <iostream> #include <cstring> #define MaxSize 1000 using namespace std; typedef struct { char data[MaxSize]; int length; /原创 2021-12-03 14:06:33 · 108 阅读 · 0 评论 -
8_Floyd算法
/** * @Author: 郑潮安yyds * @Time: 2021/12/2 18:47. * @Filename: Floyd.cpp * @Software: CLion */ #include <stdio.h> #include <stdlib.h> #define MAXN 100 #define INF 0x3f3f3f3f typedef struct struct_graph { char vexs[MAXN]; int vexnum;//顶原创 2021-12-02 21:36:33 · 139 阅读 · 0 评论 -
7_Dijkstra算法
/** * @Author: 郑潮安yyds * @Time: 2021/12/2 18:47. * @Filename: Dijkstra.cpp * @Software: CLion */ #include<queue> #include<iostream> #include<algorithm> #include <cstring> using namespace std; const int N = 100;//城市的个数可修改 const int原创 2021-12-02 19:18:27 · 831 阅读 · 0 评论 -
6_Kruskal算法
/** * @Author: 郑潮安yyds * @Time: 2021/12/2 16:30. * @Filename: union_find_set.cpp * @Software: CLion */ #include<bits/stdc++.h> using namespace std; const int MAXN = 1060; int n, m, conedEdge, sumLength, s[MAXN], height[MAXN]; int usedEdgeIndex[MAX原创 2021-12-02 18:19:48 · 120 阅读 · 0 评论 -
5_Prim算法
/** * @Author: 郑潮安yyds * @Time: 2021/12/2 15:24. * @Filename: Prim.cpp * @Software: CLion */ //最小生成树——Prime //邻接矩阵 无向图 /* *邮箱:unique_powerhouse@qq.com *blog:https://me.youkuaiyun.com/hzf0701 *注:文章若有任何问题请私信我或评论区留言,谢谢支持。 * */ #include<bits/stdc++.h> //原创 2021-12-02 16:24:34 · 156 阅读 · 0 评论 -
4_输入快读
int read(){//快读 int x=0,f=1; char c=getchar(); while(c<'0'||c>'9'){ if(c=='-') f=-1; c=getchar(); } while(c>='0'&&c<='9'){ x=x*10+c-'0'; c=getchar(); } return x*f; }原创 2021-11-30 15:33:16 · 138 阅读 · 0 评论 -
3_高精度乘
// 高精度乘法 #include <iostream> #include <string> #define N 1000 using namespace std; int main() { char num1[N]; char num2[N]; int data1[N]; int data2[N]; int result[N * 2]; memset(data1, 0, sizeof(data1)); memset(data2, 0, sizeof(data2)原创 2021-11-30 15:29:41 · 800 阅读 · 0 评论 -
2_高精度加
//高精度加 #include <cstring> #include <iostream> using namespace std; char aa[64], bb[64], cc[64]; int a[64], b[64], c[64]; int ans[64 * 3]; int add() { int len_a = strlen(aa); int len_b = strlen(bb); int len_c = strlen(cc); int tt原创 2021-11-30 15:31:44 · 155 阅读 · 0 评论 -
1_文件输入
freopen("C:\\Users\\30414\\Desktop\\洛谷新生\\input.in","r",stdin);原创 2021-11-30 15:27:09 · 115 阅读 · 0 评论
分享