自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 OneAPI 矩阵乘法

OneAPI 矩阵乘法OneAPI 是一个由英特尔(Intel)推动的跨架构编程模型和开发工具的倡议。该倡议的目标是使开发人员能够在不同类型的处理器架构上编写性能高效的代码,包括 CPU、GPU、FPGA 等。OneAPI 的设计理念是实现统一的编程模型,以便开发人员能够更容易地利用异构计算资源,而不必为每个硬件架构单独编写不同的代码。在SYCL编程模型中,函数用于指示SYCL运行时在指定的工作组内的可用工作项之间分发计算。每个工作组内的每个工作项都独立且并发地执行 lambda 表达式。

2023-12-02 17:39:21 102 1

原创 图的存储(邻接矩阵)

#include<iostream> using namespace std; #include<vector> #include<assert.h> struct graph { int n, m;//n表示点数,m表示边数 bool directed;//表示是否是有向图,还是无向图 vector<vector<bool>>g;//邻接矩阵 }; //初识化图 void Init(graph&t,int n,bool direc.

2021-10-03 20:12:56 96

原创 快速排序c++

#include<iostream> using namespace std; int Partition(int a[], int left, int right) { int temp = a[left]; while (left < right) { while (left<right && a[right]>temp)right--; a[left] = a[right]; while (left < right &&a.

2021-09-09 22:02:58 84

原创 归并排序的递归版本

#include<iostream> using namespace std; const int N = 100010; //把a数组[L1,R1]和[L2,R2]合并成有序区间 void merge(int a[], int L1, int R1, int L2, int R2) { int i = L1, j = L2, index = 0; int temp[N]; while (i <= R1 && j <= R2) { if (a[i] &l.

2021-08-12 11:26:09 90

原创 求二叉树左叶子节点的权值之和的两种方法

1.通用的方法(求有右叶子节点之和也行):深度优先遍历(递归) intminDepth(TreeNode*root) { if(!root)return0; elseif(!root->left&&!root->right)return1; elseif(root->left&&!root->right)return1+minDepth(root->lef...

2021-08-07 17:44:08 930

原创 求二叉树最大深度的两种方法和最小深度的两种方法

1.深度优先搜索(递归) int maxDepth(TreeNode* root) { if(!root)return 0; else return max(maxDepth(root->left),maxDepth(root->right))+1; } 2.层序遍历,看看二叉树一共有多少层。 int maxDepth(TreeNode* root) { int depth=0;

2021-08-07 14:50:04 141

原创 二叉树的非递归中序遍历

vector<int> inorderTraversal(TreeNode* root) { vector<int>res; stack<TreeNode*>s; TreeNode*cur=root; while(cur||!s.empty()) { while(cur) { s.push(cu...

2021-08-07 11:05:17 68

原创 floy算法(龟兔赛跑):监测单链表是否存在环路

bool hasCycle(ListNode *head) { ListNode*slow=head,*quick=head; while(quick&&quick->next) { slow=slow->next; quick=quick->next->next; if(quick==slow)return true; ...

2021-08-06 19:50:45 90

原创 优化后(随机)的快速排序

#include<iostream> #include<stdlib.h> #include<time.h> #include<math.h> using namespace std; int Partition(int a[], int l, int r) { srand((unsigned)time(NULL)); int p = (int)(round(1.0 * rand() / RAND_MAX * (r - l) + l)); ...

2021-08-06 19:44:23 120

原创 链表的翻转

ListNode* reverseList(ListNode* head) { //当前结点的上一个节点 ListNode*pre=NULL; ListNode*cur=head; while(cur) { ListNode*next=cur->next; cur->next=pre; pre=cur; ...

2021-08-04 22:51:09 67

原创 链表的设计

class MyLinkedList { public: /** Initialize your data structure here. */ struct ListNode { int val; ListNode*next; ListNode(int val):val(val),next(nullptr){} }; ListNode*_dummyHead; int _size; MyLinkedLis...

2021-08-04 22:35:25 74

原创 二分法找重复元素的边界问题

给定一个按照升序排列的整数数组 nums,和一个目标值 target。找出给定目标值在数组中的开始位置和结束位置。 如果数组中不存在目标值 target,返回[-1, -1]。 vector<int> searchRange(vector<int>& nums, int target) { if(nums.size()==0)return{-1,-1}; int left=0; int right=nu.

2021-08-04 17:20:52 205 1

原创 链表的定义和基本操作

#include<iostream> using namespace std; //结点的定义 typedef struct LNode { int data; LNode*next; }LNode,*LinkList; //初始化带头结点的单链表 bool InitList(LinkList&L) { //头结点 L = (LNode*)malloc(sizeof(LNode)); //如果分配内存失败,则初始化失败 if (L ==NULL)return false; .

2021-08-04 14:35:50 102

原创 顺序表与链表的优缺点

顺序表的优点:可进行随机存取,存储密度高。 缺点:要求大片连续空间,改变容量不方便。 单链表的优点:不要求大片连续空间,改变容量方便 缺点:不可以进行随机存取,而且要耗费一定空间去存放指针。 ...

2021-08-04 11:37:32 352

原创 最基础的整数二分查找法,严格递增情况使用,注意退出条件:当[left,right]变成空区间退出循环即可。

#include<iostream> using namespace std; #include<vector> int binarySearch(vector<int>nums,int target) { int left = 0; int right = nums.size(); while (left <= right) { int mid = left + (right - left) / 2; if (target == nums[mid.

2021-08-03 21:43:40 64

原创 动态数组实现顺序表,仅仅只能改变数组大小,没有什么大的意义

#include<iostream> using namespace std; #define InitSize 10 //静态数组是无法改变数组的大小,而动态数组可以改变这个问题 //动态数组的定义 typedef struct { //动态数组 int* data; //数组的最大长度 int Maxsize; //顺序表的长度 int length; }SqList; //初始化顺序表 void InitList(SqList& L)...

2021-08-03 17:19:54 85

原创 静态顺序表的定义与基本操作

#include<iostream> using namespace std; #define Maxsize 10 //定义一个静态存储的顺序表 typedef struct { //定义数组的最大长度 int data[Maxsize]; //线性表的长度 int length; }SqList; //初始化顺序表,采用引用的方式带回来结果 void InitList(SqList&L) { //将所有数据元素设置为默认初识值 for (int i = 0; i &lt.

2021-08-03 12:37:37 169

原创 2021-07-17

class Solution { public: vector<int> searchRange(vector<int>& nums, int target) { int left=0; int right=nums.size()-1; int l=-1; int r=-1; while(left<=right) { .

2021-07-17 15:25:55 54

原创 2021-05-07

#include<iostream> using namespace std; #include <cstdlib> #include<fstream> #define MAX 1000 #include<string> //联系人结构体 struct Person { string name; int sex; int age; string phone; string address; }; //通讯录结构体 str...

2021-05-07 06:55:31 152

空空如也

空空如也

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

TA关注的人

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