weinan030416

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

随笔分类 - 

收集一些有意思的代码
算法
摘要:分解自然数之和可重复,乘积最大 #include<bits/stdc++.h> using namespace std; //根据数学知识,分成若干个2和3 int maxn=0; //最大乘积 void find(int num,int cur) { if(cur>maxn){ maxn=cur; 阅读全文

posted @ 2023-10-29 10:04 楠030416 阅读(8) 评论(0) 推荐(0) 编辑

修改数组
摘要:通过80% #include<bits/stdc++.h> using namespace std; int n,num[100001]; void fun(int i){ bool total[100001]; memset(total,false,sizeof(total)); for(int 阅读全文

posted @ 2023-03-28 20:17 楠030416 阅读(21) 评论(0) 推荐(0) 编辑

算法
摘要:#include<bits/stdc++.h> using namespace std; int N,M,K,T,Time[100],Begin[100],To[100][100][100],Total[100]; bool Have[100]; void dfs(int i,int j,int m 阅读全文

posted @ 2023-03-28 15:27 楠030416 阅读(13) 评论(0) 推荐(0) 编辑

十字链表
摘要:存储稀疏矩阵 十字链表法,十字链表压缩存储稀疏矩阵详解 (biancheng.net) 阅读全文

posted @ 2023-02-03 22:11 楠030416 阅读(78) 评论(0) 推荐(0) 编辑

KMP
摘要:#include<iostream> #include<string.h> #include<stdio.h> #include<fstream> using namespace std; int next[10]; void Next(char*T,int n) { int i=1,j=0; ne 阅读全文

posted @ 2023-02-02 09:13 楠030416 阅读(73) 评论(0) 推荐(0) 编辑

排序
摘要:冒泡 #include<iostream> #include<algorithm> #include<cmath> using namespace std; const int N=100000; int n; int nums[N]; int main() { scanf("%d",&n); fo 阅读全文

posted @ 2023-02-02 08:43 楠030416 阅读(13) 评论(0) 推荐(0) 编辑

距离和最小
摘要:#include<iostream> #include<algorithm> using namespace std; int main() { int n,place,i; cin>>n; int a[n]; for(i=0;i<n;i++) { cin>>a[i]; } sort(a,a+n); 阅读全文

posted @ 2023-01-26 15:07 楠030416 阅读(11) 评论(0) 推荐(0) 编辑

二分查找
摘要:三次方根 直接写 #include<iostream> #include<cmath> #include<iomanip> using namespace std; double n; int main() { bool sign; cin>>n; double l=-10000,r=10000; 阅读全文

posted @ 2023-01-26 14:51 楠030416 阅读(18) 评论(0) 推荐(0) 编辑

排序
摘要:快速排序 #include<iostream> using namespace std; int nums[100]; void quicksort(int num[],int left,int right) { if(left>=right) return; int target=nums[lef 阅读全文

posted @ 2023-01-26 13:39 楠030416 阅读(18) 评论(0) 推荐(0) 编辑

递归初体验
摘要:求斐波那契数列 #include<bits/stdc++.h> using namespace std; int rab(int n) { if(n==1) return 1; if(n==2) return 1; else return rab(n-1)+rab(n-2); } int main( 阅读全文

posted @ 2023-01-25 21:25 楠030416 阅读(18) 评论(0) 推荐(0) 编辑

栈和队列
摘要:栈一般数组和链表两种实现方式 栈:先进后出、尾入尾出 class Stack{ private: int *data;//存放栈中的数据 int maxsize;//栈最大空间 int top;//栈顶 public: //默认空间为10 Stack() //初始化栈 { maxsize = 10; 阅读全文

posted @ 2023-01-07 15:54 楠030416 阅读(14) 评论(0) 推荐(0) 编辑

C++文件操作
摘要:C++文件操作分为两种i/o fstream和文件指针 ofstream 和 ifstream🤪 #include<fstream>//头文件 以读方式打开 char word; ifstream in; in.open("a.txt"); in>>word; in.close(); 这种方式不会 阅读全文

posted @ 2022-12-27 16:29 楠030416 阅读(41) 评论(0) 推荐(0) 编辑

只用一个头结点一个头指针的链表写法
摘要:#include<iostream> #include<stdlib.h> using namespace std; struct Node { int data; struct Node *next; }; int main() { int num,n; cin>>num; Node *head, 阅读全文

posted @ 2022-10-18 21:44 楠030416 阅读(19) 评论(0) 推荐(0) 编辑

链表实现
摘要:输入数字并输出的链表 #include<iostream> #include <stdlib.h> using namespace std; ​ struct Node { int data; struct Node*next; }; ​ int main() { int num; cin>>num 阅读全文

posted @ 2022-10-05 09:56 楠030416 阅读(18) 评论(0) 推荐(0) 编辑

递归函数的分析
摘要:自己写了一个奇奇怪怪的递归函数 #include<iostream> using namespace std; int i=0,j=0; void dfs(int u); void tfs(int u) { if(u>3) { return; } j++; cout<<"j="<<j<<" "<<" 阅读全文

posted @ 2022-09-12 19:41 楠030416 阅读(61) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示