自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(25)
  • 收藏
  • 关注

原创 相对路径和绝对路径

相对路径和绝对路径

2022-06-20 11:36:58 97 1

原创 通讯录信息系统的管理

数据结构实验报告,链表,通讯录信息系统的管理

2022-06-07 22:14:30 148

原创 mac的vscode编译环境设置

vscode编译环境设置这边建议直接前往这是b站的一个up主的视频讲解一步一步跟着做就ok的,讲的非常详细。题主亲测绝对有效。https://www.bilibili.com/video/BV1U741157Rd?spm_id_from=333.999.0.0除此之外可能部分同学还对编写c++的万能头文件可能有需求可以看看题主的另一篇文章哦https://blog.csdn.net/weixin_49833175/article/details/122310800...

2022-01-04 20:34:03 466

原创 vscode编译器添加c++万能头文件

在我目前遇到的就是使用xcode以及vscode时需要自行添加万能头才可以在代码中使用。他们的本质都是找到软件中储存库函数的文件夹中再添加一个自行需要的函数。下面就以vscode举例1.写一行#include<iostream>2.对iostream右击点转到定义3.打开之后对文件框上的iostream右击在Finder显示4.创建bits文件夹5.在文件夹内创建文本6.将下面的代码块粘贴到文本内部就ok啦// C++ includes used for precom

2022-01-04 20:30:35 3745 3

原创 2021-09-17

1.排序算法排序算法主要为快速排序,归并排序等八大排序。归并排序其中一项应用为求逆序对。快速排序:void quick_sort(int q[],int l,int r){ if(l>=r) return; int x=q[l+r>>1];int i=l-1,j=r+1; while(i<j) { do i++; while(q[i]<x);

2021-09-17 08:17:40 46

原创 最短路问题

最短路问题可以分为两种,单源最短路和多源汇最短路。单源最短路问题分为:正权边问题和存在负权边的问题。(n为点数,m为边)正权边问题:1.朴素dijkstra算法时间复杂度为O(n^2),适用于稠密图,通常用邻接矩阵存图。核心代码。int g[N][N];//存图int dis[N];//存起点到当前点的距离bool st[N];//判断点是否被更新int dijkstra(){ memset(dis,0x3f,sizeof dis); dis[1]=0;//初始化起点

2021-08-02 22:23:34 133

原创 洛谷P1249

链接:link//贪心法本题3,4需要额外处理,其余则用从2累加到sum==n||sum-n>1,x=sum-n;x则为累加中需要去掉的一项。# include <bits/stdc++.h>using namespace std;# define ll long longint n;vector<int> mul(vector<int> &xp,int x){ vector<int>c;int t=0; for

2021-07-09 12:39:11 131

原创 洛谷P3397

链接: link.本题可以直接使用二维差分。给以(x1, y1)为左上角,(x2, y2)为右下角的子矩阵中的所有元素加上c。S[x1, y1] += c, S[x2 + 1, y1] -= c, S[x1, y2 + 1] -= c, S[x2 + 1, y2 + 1] += c# include <bits/stdc++.h>using namespace std;# define ll long longconst int N=1000+10;int a[N][N];

2021-07-09 12:06:16 61

原创 1807待改

下面展示一些 内联代码片。#include<iostream># include <cstdio># include <vector># include <algorithm># define ll long longusing namespace std;struct road{ int u,v; int dis; int link;}p[50001];int h[1501];int n,m;int vis[1

2021-04-19 20:37:52 71

原创 第十二届蓝桥杯F题

递归。#include<iostream># include <cstdio># include <vector># include <algorithm># define ll long longusing namespace std;int a[101];int n;int b[3]={-1,0,1};int w[100001];void fx(int i,int weight){ if(i==n+1) {

2021-04-19 09:37:44 91

原创 超时待改

java B [蓝桥杯2018决赛]版本分支//超时emm#include<iostream># include <cstdio># include <vector># define ll long longusing namespace std;int a[100001];int vis[100001];int find(int fa,int son){ while(a[son]!=fa&&a[son]!=1&&

2021-04-17 19:59:47 44

原创 博弈论

1.巴什博弈假设有一堆石子n个,两个人A,B依次取出一定数量的石子,最少取一个,最多不超过k个,A先手,B后手,最后取光者获胜。A必胜的条件n%(k+1)!=0B必胜的条件相反2.威佐夫博弈假设有两堆石子a,b个,swap(a,b)保证(a<b)先取完者获胜。double x=(sqrt(5.0)+1)/2.0;if(x*(b-a)==a)先手必败。else先手必胜。...

2021-01-31 22:25:50 90 1

原创 数据结构二叉树的创建与遍历

代码如下# include <iostream># include <stdlib.h>using namespace std;struct TreePoint{ char data;//储存结点数据 struct TreePoint *l,*r;//储存左支树和右支树的指针};//创建二叉树链表void CreateTree(struct TreePoint **t){ char c; cin>>c; if('#'==

2021-01-29 17:34:23 314

原创 kmp算法代码

# include <iostream># include <string>using namespace std;void get_next(string a,int *next){ int i=-1,j=0; next[0]=-1;//方便起见将next[0]赋值为-1; while(j<a.length()-1){ if(-1==i||a[i]==a[j]){ ++i; ++j

2021-01-27 13:36:12 108

原创 判断条件下字符串长度比较问题

在编程过程中发现如下问题在编写c++代码时while语句(判断比较i和a.length())//a为string类型while会莫名其妙的停止只执行一次就跳出来。经过多次尝试发现当判断语句中出现a.length()和一个负数比较时,即便条件成立,无论是if还是while等都会立即跳出来,结束语句执行例如:# include<iostream># include<string>using namespace std;int main(){ string

2021-01-27 11:18:07 235

原创 汉诺塔问题

汉诺塔问题代码如下# include <iostream>using namespace std;void move(int n,char x,char y,char z){ if(1==n) cout<<x<<"->"<<z<<endl;//确定返回条件避免无限递归 else{ move(n-1,x,z,y); //将 n-1 个圆盘从x借助z移动到y上

2021-01-25 17:31:36 69

原创 PTA-011A-B问题

本题要求你计算A−B。不过麻烦的是,A和B都是字符串 —— 即从字符串A中把字符串B所包含的字符全删掉,剩下的字符组成的就是字符串A−B。代码如下# include <iostream># include <string>int i,j;using namespace std;int main(){ string a,b; getline(cin,a); getline(cin,b); for(j=0;a[j]!='\0';++j){

2021-01-25 16:28:04 105

原创 数据结构队列c++

数据结构中队列的基本操作初始化,入队,出队,销毁。下面展示代码。# include<iostream># include <stdlib.h>using namespace std;struct z{ char data; struct z *next;};//定义链表结构体struct queue{ struct z *head; struct z *tail;};//定义指向链表头和尾的指针struct queue* init_

2021-01-24 21:00:23 96

原创 数据结构栈c++

数据结构中栈的基本操作初始化,判断栈空,压栈,出栈,取栈顶元素下面展示 代码。# include <iostream># include <stdlib.h>using namespace std;# define MAX 20struct z{ int data[MAX]; int top;};//定义栈结构体,struct z* init_f(){ struct z *s; s=(struct z *)malloc(sizeof(

2021-01-24 20:49:57 72

原创 数据结构链表

单链表——快慢链表下面展示 代码。# include<iostream>using namespace std;struct node{ int data; struct node *next;};//创建结构体int main(){ struct node *head,*p;//定义头指针,头结点 int i; srand((unsigned)time(NULL));//随机生成数 head=(struct node*)malloc(

2021-01-24 20:44:56 50

原创 PTA,L1-006连续因子c代码

*一个正整数 N 的因子中可能存在若干连续的数字。例如 630 可以分解为 3×5×6×7,其中 5、6、7 就是 3 个连续的数字。给定任一正整数 N,要求编写程序求出最长连续因子的个数,并输出最小的连续因子序列。输入格式:输入在一行中给出一个正整数 N(1<N<2​31​​ )。输出格式:首先在第 1 行输出最长连续因子的个数;然后在第 2 行中按 因子1因子2……因子k 的格式输出最小的连续因子序列,其中因子按递增顺序输出,1 不算在内。代码:# include <s

2021-01-17 19:38:21 386

原创 c语言中整型变量四舍五入问题

最近在学习中遇到这样的问题经过总结出以下几点:通常情况下c语言自动向下取整,但是在输出时保留小数位数时是按照四舍五入来进行的。下面举一个简单的例子。# include <stdio.h># include <math.h>int main(){ int a; scanf("%d",&a); printf("%lf\n%.0lf\n%d\n",sqrt(a),sqrt(a),a/2); return 0;}运行结果:输入:31.

2021-01-12 22:43:59 4018

原创 斐波那契数列代码

include <stdio.h>int main (void){int a;int f1 = 1,f2 = 1,f3;int i;scanf("%d",&a);//输入的a有取值范围if ((a == 1)||(a == 2)){printf(“1\n”);}else if ((a>1)&&(a<=40)){for (i = 3;i<=a;++i){f3=f2+f1;f1=f2;f2=f3;}printf("%d\

2020-10-11 15:51:18 875

原创 求一百以内的完全平方数

//求一百以内的完全平方数include <stdio.h>include <math.h>void f(int );int main (void){int i;for (i = 1;i<=100;++i){f(i);}return 0;}void f(int a){int b;b = (int)sqrt(a);if (a == b*b){printf("%d\n",a);}}

2020-10-07 19:42:52 1166

原创 求一百以内的素数,函数

//求一百以内的素数include <stdio.h>void f(int );int main (void){int i;for (i = 2;i<=100;++i){f(i);}return 0;}void f(int x){int i;for ( i = 2;i<x;++i){if (x%i == 0)break;}if ( i ==x)printf("%d\n,x);}//本程序关键在于构造求素数的函数,重点循环中最后输出的i与x

2020-10-07 19:32:43 742 1

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除