自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 algorithm头文件初涉

max(x,y)最大值min(x,y)最小值abs(x)绝对值,x必须为整数fabs(x)绝对值,浮点型(math)头文件swap(x,y)交换x,yreverse(it,it2)将数组指针在【it,it2)之间的元素或容器的迭代器(??)的元素进行反转next_permutation(it,it2)给出一个序列[it,it2)在全排列中的下一个序列fill(it,it2,a)可以把[it,it2)中赋值为asort(it,it2,cmp)sort为排序函数,cmp为比较函数,若无比较函数则

2021-04-11 19:44:32 119

原创 欧几里得扩展算法深究

欧几里得扩展算法#include<stdio.h>int exgcd(int a,int b,int &x,int &y){ if(b==0){ x=1;y=0;return a; } int t=exgcd(b,a%b,x,y); int x0=x,y0=y; x=y0; y=x0-(a/b)*y0; return t;}int main(){ int a,b,c,x,y,gcd; printf("请输入公式 a*x + b*y + c = 0"

2021-01-25 17:19:17 90

原创 排序深究

归并排序#include<stdio.h>int a[10000],a2[10000];//序列和临时序列,//临时序列存储在合并过程已经排序好的数列,然后存储给序列 void Merge(int sta,int mid,int end){ int k=0;//k等于0或i都可以,如果随便就会发生越界 int i; i=sta; int j; j=mid+1; while(i<=mid&&j<=end){ if(a[i]<a[j]){//

2021-01-22 19:48:38 77

原创 进制转换问题深究

输入一个十进制数N,将它转换成R进制数输出。输入数据包含多个测试实例,对于每组测试用例:输入两个整数N( 0 <= N <= 10^8) 和 R(2 <= R < 10)。输出转换后的数,输出后换行。#include<stdio.h>#include<string.h>long long int n,r,count;void print(long long int x){ if(x<=9)printf("%lld",x); els

2021-01-21 16:49:04 119

原创 欧几里得算法初学

欧几里得初学给a与b两个数球最大公约数,一般我都是从较小的那个数开始检测是不是,然后减一,在重复检测;但欧几里得算法可以减少算法时间很多人知道欧几里得的使用,会打欧几里得的代码,但并不知道欧几里得算法的数学原理;#include<stdio.h>int main(){ int m,n,r; while(scanf("%d%d",&m,&n)!=EOF){ printf("%d和%d的最大公因子是\n",m,n); while(n!=0){ r=m%n

2021-01-20 16:56:36 101

原创 并查集2.0

路径压缩,按秩合并int disjoint[1024];int rank[1024];//秩指的就是你下面有几层小弟; void red(void){ for(int i=0;i<1024;i++){ disjoint[i]=i; rank[i]=0; }}int find(int i){//查询函数,这个函数相比于前一次,增 if(disjoint[]==i) return 0;//加了路径压缩功能 。 else{ disjoint[i]=find(disjoi

2021-01-08 19:16:27 54

原创 并查集1.0

Dragon BallsFive hundred years later, the number of dragon balls will increase unexpectedly, so it’s too difficult for Monkey King(WuKong) to gather all of the dragon balls together.His country has N cities and there are exactly N dragon balls in the wor

2021-01-08 18:21:03 79

原创 广度搜索初学2.0

Catch That CowFarmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,000) on a number line and the cow is at a point K (0 ≤ K ≤ 100,000) on the same number line. Farmer John

2021-01-07 19:03:23 105

原创 广度搜索初学1.0

迷宫问题定义一个二维数组:int maze[5][5] = {0, 1, 0, 0, 0,0, 1, 0, 1, 0,0, 0, 0, 0, 0,0, 1, 1, 1, 0,0, 0, 0, 1, 0,};它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线。Input一个5 × 5的二维数组,表示一个迷宫。数据保证有唯一解。Output左上角到右下角的最短路径,格式如样例所示。Sample Inp

2021-01-07 19:01:05 77

原创 链表初学

链表1.0#include<stdio.h>//链表#include<stdlib.h>//c++基本库 typedef struct node{//创建链表节点 int value;//链表储存元素 struct node *next; //指向下一个链表 }Node; //改名, int main(){ Node *head=NULL;//建立链表的开头 int number; do{ scanf("%d",&number); if(

2021-01-06 21:37:26 78

空空如也

空空如也

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

TA关注的人

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