自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 完整K-Means算法的实现及聚类结果;sklearn中的kMeans

在数据集data.csv上评价 K-Means 算法的聚类结果。在数据集data.csv上评价 K-Means 算法的聚类结果。对比分析与自己实验的kmeans聚类的实验结果的差异。绘出质心与所属样本欢迎使用Markdown编辑器。调用sklearn中提供的kMeans算法。加载数据,调用上述函数,评价聚类结果。补全完整的K-Means算法代码。

2023-03-26 19:28:41 290

原创 线性回归应用:预测医疗费用

线性回归预测 比较自定义函数和sklearn函数预测

2022-09-09 00:00:00 1473

原创 线性回归(一元、多元、应用)

线性回归一元、多元、应用:预测医疗费用 比较自定义函数预测和sklearn

2022-09-04 14:25:24 593

原创 线段树的创建/查询 C++

线段树是一种应对多次查询的快速数据结构。函数Build的功能是,针对a[left]…a[right],建立线段树,存于tree[k]

2022-08-02 16:38:48 159

原创 八皇后问题 C++ 栈

八皇后问题是标准的回溯法的应用。一般采用栈存储布局,非常简练。以下Solve函数,存储了n皇后的[0,i-1]行的布局,求解n皇后的[i,n-1]行的布局。

2022-08-02 16:32:46 429

原创 约瑟夫问题 C++(list)

约瑟夫问题是n个人排成一圈,数到k出队列,计算出圈的次序。一般利用循环链表进行求解。但是利用STL中的list,可以更加方便。以下函数输出所有人的出圈次序。

2022-08-02 16:26:42 341

原创 LeetCode20. 有效的括号

1、C++ 中使用哈希表(unordered_map)的常用操作2、思路:

2022-08-02 16:20:27 131

原创 高精度整数求幂求和

高精度数用一个数组去示一个数字。这样这个数字就被称谓是高精度数基本思路:​ 1、读入数字保存在字符数组中。​ 2、字符数组高精度数的位数保存在整型数组的a[0]中。​ 3、将字符串中的字符逐个转化成数字并保存在整型数组a中。在存储时需要倒序存储。a[n++] 是 先n加一高精度整数求幂#include<iostream>using namespace std;class BigInt{public: int n; int a[10000].

2022-05-05 15:30:47 203

转载 力扣上的代码想在本地编译运行?

https://mp.weixin.qq.com/s/r1696t8lvcw7Rz4gb_jacw力扣上的代码想在本地编译运行?

2022-03-03 22:38:47 350

原创 蛇形矩阵C++

蛇形矩阵eg:#include<iostream>#include<iomanip>using namespace std;#define N 10void Output(int a[N][N], int n){ for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cout << setw(4) << a[i][j]; } cout &l

2022-02-27 23:54:18 633

原创 回型矩阵C++

1、双重循环#include<iostream>#include<iomanip>using namespace std;#define N 10void Output(int a[N][N], int n){ for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cout << setw(5) << a[i][j] << " "; }

2022-02-27 23:53:38 1273 1

原创 Leetcode1380. 矩阵中的幸运数

矩阵中的幸运数代码:class Solution {public: vector<int> luckyNumbers(vector<vector<int>>& matrix) { int m = matrix.size(); int n = matrix[0].size(); vector<int> row(m, INT_MAX), col(n, INT_MIN); vector<int> ans; for .

2022-02-16 00:01:25 230

原创 Leetcode217. 存在重复元素

存在重复元素代码一:排序然后比较相邻数字是否相同代码二:(哈希表)class Solution {public: bool containsDuplicate(vector<int>& nums) { set<int>s; for (int x : nums) { if (s.find(x) != s.end()) { return true; } s.insert(x); } return false; }};.

2022-02-15 20:32:51 300

原创 Leetcode9. 回文数

思路:由示例2可知负数不是回文数由示例3可知末位不能为0并且不是0这单个数字(0是回文数)若回文数长度是奇数时候,反转后的reverted多一位中间数字,需要reverted/10去掉代码:class Solution {public: bool isPalindrome(int x) { if (x < 0 || (x % 10) == 0 && x != 0) { return false; }

2022-02-15 00:14:47 188

原创 Leetcode1. 两数之和

暴力求解:class Solution {public: vector<int> twoSum(vector<int>& nums, int target) { int i, j; for (i = 0; i < nums.size()-1; i++) { for (j = i+1; j < nums.size(); j++) { if (nums[i] + num

2022-02-14 13:44:15 471

原创 各种排序算法

#include<iostream>using namespace std;void SelectSort(int r[],int n);//选择排序void InsertSort(int r[],int n);//直接插入排序void BinInsertSort(int r[],int n);//折半插入排序void ShellSort(int r[],int n);//希尔排序void Partition(int r[],int i,int j);//快速排序void Sift

2022-02-07 21:24:21 243

原创 如何获得数组长度

strlen函数只能用于字符串数组strlen(char)其他类型数组:sizeof(array)/sizeof(array[0])

2022-01-16 23:28:20 299

原创 BF算法模式匹配

#include<iostream>using namespace std;int findstr(char* mainstr, char* sonstr);int main() { char mainstr[100], sonstr[100]; while (1) { cin >> mainstr >> sonstr; int set = findstr(mainstr, sonstr); if (set == -1) cout <

2022-01-09 09:57:05 287

原创 链表逆置、合并和相关其他函数

test.h#include<bits/stdc++.h>#ifndef TEST_H #define TEST_Husing namespace std;template <class T> class Node{public: T data; Node<T> *next; Node(T data=0){this->data=data;this->next=NULL;}};template <class T>cl

2022-01-09 09:50:53 76

原创 线索二叉树

BiTree.h#include <vector>#include <iostream>using namespace std;enum BiThrNodeType{LINK,THREAD};template <class T>struct BiNode{ BiThrNodeType ltype,rtype; T data; BiNode<T> *lchild; BiNode<T> *rchild;};static BiN

2022-01-04 01:09:31 227

原创 CH7(1) 二叉树

// 二叉树2.cpp : Defines the entry point for the console application.//#include<iostream>#include<vector>#include<string>using namespace std;template<class T>struct BiNode{ T data; BiNode <T>* lchild; BiNode <T&gt

2022-01-03 20:57:34 688

原创 哈夫曼树各种函数

HuffmanTree.h#ifndef HUFFMANTREE_H#define HUFFMANTREE_H#include<iostream>#include<vector>using namespace std;struct HuffmanNode{ char data; double weight; int parent,lchild,rchild;};class HuffmanTree{private: vector<HuffmanNod

2022-01-02 16:12:28 309

原创 CH9 二分查找和二叉排序树查找

BiSortTree.h#pragma once#include<iostream>using namespace std;struct Binode{ int key; Binode* lchild, * rchild;};class BiSortTree{ Binode* root; void Insert(Binode*& ptr, int k); Binode* Search(Binode* ptr, int k); void Free(Binode

2022-01-02 16:06:45 132

原创 CH8 图 (C++类模板)

MyGraph.h#ifndef MYGRAPH_H#define MYGRAPH_H#include <iostream>#include <cstring>#include <queue>#include <vector>#include <iomanip>#include <math.h>using namespace std;template <class T>struct Edge{

2022-01-02 16:04:44 205

原创 CH7(2)哈夫曼树 (C++类模板)

Huffman.h#pragma once#ifndef HUFFMAN_H#define HUFFMAN_H#include <iostream>#include <vector>#include <cstring>using namespace std;struct HuffmanNode{ char data; double weight; int parent, lchild, rchild; vector<char>co

2022-01-02 16:03:09 152

原创 CH3 中缀表达式(C++类模板)

SeqStack.hpp#include<iostream>using namespace std;template <class T, int Maxsize >class SeqStack{ T data[Maxsize];//存放栈元素的数组 int top;//栈顶指针,指示栈顶元素在数组中的下标public:public: SeqStack();//构造函数 void Push(T x);//入栈 int Stacktop();//返回栈顶元素 T

2022-01-02 15:59:40 188

原创 CH2 合并有序顺序表和有序链表(C++类模板)

SeqList.hpp#pragma once#include<iostream>using namespace std;template<class T, int MaxSize>class SeqList{ T data[MaxSize]; int length;public: int MaxSize; SeqList(); SeqList(T a[], int n); int ListLength(); void CreatSeqlist(int

2022-01-02 15:57:27 130

原创 二叉树(C++类模板)

BiTree.h#ifndef BITREE_H#define BITREE_H#include<vector>#include<iostream>using namespace std;template <class T>struct BiNode { T data; // 结点数据 BiNode<T> *lchild; // 左孩子的指针 BiNode<T> *rchild; // 右孩子的指针

2022-01-02 04:06:58 672

原创 合并有序顺序表和有序链表

SeqList.hpp#pragma once#include<iostream>using namespace std;template<class T, int MaxSize>class SeqList{ T data[MaxSize]; int length;public: int MaxSize; SeqList(); SeqList(T a[], int n); int ListLength(); void CreatSeqlist(int

2021-12-28 08:56:46 117

原创 求最大子串

#include<iostream>using namespace std;int MaxSub(char a[],char b[],char c[]);void Sub(int m,int n,char a[],char b[]);void MyCopy(char a[],char b[]);int SubStr(char a[],char b[]);int main(){ char a[100],b[100],c[100]; int i=0; cout<<"请

2021-12-27 23:17:30 202

原创 KMP算法

```cpp在这里插入代码片

2021-12-27 23:14:46 79

原创 C++把类分文件

如何代码整体左移全选代码 然后shift+Tab如何把类分文件eg:class Point{public: void setX(int x) { cout << "请输入x" << endl; cin >> x; X = x; } int getX() { return X; } void setY(int y) { cout << "请输入y" << endl; cin >..

2021-08-15 01:04:57 274

原创 C++判断点和圆的关系

#include<iostream>#include<string>#include<math.h>using namespace std;class Point{public: void setX(int x) { X = x; } int getX() { return X; } void setY(int y) { Y = y; } int getY() { return Y; } void setZ(

2021-08-15 00:32:09 750

原创 C++中平方、开方、绝对值

#include<math.h>平方int a = pow(c.getCenter().getX() - p.getX()),2);开方int b = sqrt(pow((c.getCenter().getX() - p.getX()),2) + pow((c.getCenter().getY() - p.getY()),2) + pow((c.getCenter().getZ() - p.getZ()),2));//圆心到点的距离绝对值(整数)int a = a

2021-08-14 23:13:30 794

原创 蓝桥杯

蓝桥杯题目 1083: Hello, world! 题解C语言`#include<stdio.h>int main(){ int a; while (scanf("%d",&a) != EOF){ printf("%c",a); } return 0;}`C++#include<iostream>#include<cstdio>using namespace std;int main(){ int data;

2021-02-22 16:25:07 144

空空如也

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

TA关注的人

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