自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(60)
  • 问答 (1)
  • 收藏
  • 关注

原创 1049. 最后一块石头的重量 II

有一堆石头,每块石头的重量都是正整数。> > 每一回合,从中选出任意两块石头,然后将它们一起粉碎。假设石头的重量分别为 x 和 y,且 x > 如果 x == y,那么两块石头都会被完全粉碎;> 如果 x != y,那么重量为 x 的石头将会完全粉碎,而重量为 y 的石头新重量为y-x。> 最后,最多只会剩下一块石头。返回此石头最小的可能重量。如果没有石头剩下,就返回 0。> > 示例: > 输入:

2022-10-09 17:54:03 205 1

原创 lettcode-55. 跳跃游戏II

给定一个非负整数数组,你最初位于数组的第一个位置。数组中的每个元素代表你在该位置可以跳跃的最大长度。你的目标是使用最少的跳跃次数到达数组的最后一个位置。示例:- 输入: [2,3,1,1,4]- 输出: 2- 解释: 跳到最后一个位置的最小跳跃数是 2。从下标为 0 跳到下标为 1 的位置,跳 1 步,然后跳 3 步到达数组的最后一个位置。说明: 假设你总是可以到达数组的最后一个位置。

2022-10-04 16:45:21 142

原创 leetcode55.跳跃游戏

leetcode55.跳跃游戏

2022-10-04 12:38:30 139

原创 53. 最大子数组和

53. 最大子数组和

2022-10-01 21:49:56 123

原创 376. 摆动序列

376. 摆动序列

2022-10-01 12:13:57 62

原创 leetcode_455. 分发饼干

leetcode_455. 分发饼干

2022-10-01 11:20:59 67

原创 452-用最少数量的箭引爆气球

452-用最少数量的箭引爆气球

2022-09-30 22:52:17 65

原创 135. 分发糖果

135. 分发糖果

2022-09-27 13:22:05 239

原创 860.柠檬水找零

860.柠檬水找零

2022-09-27 12:40:15 60

原创 122.买卖股票的最佳时机II

122.买卖股票的最佳时机II

2022-09-24 23:58:15 67

原创 2021-04-19

#include<iostream>using namespace std;#pragma warning (disable:4996)#define maxSize 100/*赫夫曼树的存储结构,它也是一种二叉树结构,这种存储结构既适合表示树,也适合表示森林。*/typedef struct Node{ int weight; //权值 int parent; //父节点的序号,为-1的是根节点

2021-04-19 21:24:39 50

原创 一元多项式加法

#include<iostream>using namespace std;struct ployn { float coef; //系数 int exp; //指数 ployn* next;};//创建多项式/*创建带头结点的链表(多项式)且无论按什么顺序输入,或是有相同指数项最终在多项式中都是升幂顺序!*/void CreatePolyn(ployn*& P, int m){ ployn* pre, * paixv, * q, *

2021-04-12 21:59:53 160

原创 STL标准容器 (list)

案例 -评委打分#include<iostream>using namespace std;#include"string"#include<vector>#include<deque>#include<algorithm>#include<ctime>class Person{public: Person(string name, int score) { this->m_Name = name; this

2020-12-26 01:10:04 109

原创 2020-12-23

001 deque 容器_排序sort 算法非常使用 ,使用时包含文件algorithm即可#include<iostream>#include<deque>using namespace std;#include<algorithm>void printDeque(const deque<int>& d){ for (deque<int>::const_iterator it = d.begin(); it != d.

2020-12-23 23:47:47 77

原创 STL string 容器

string 插入和删除#include<iostream>#include<string>using namespace std;void test01(){ string str = "hello"; //插入 str.insert(1, "111"); cout << str << endl; //删除 str.erase(1, 3); cout << str << endl;}int mai

2020-12-23 17:20:24 71

原创 STL vector 容器

01 vector 容器#include<iostream>using namespace std;#include<vector>void printVector(vector<int>& v){ for (vector<int>::iterator it = v.begin(); it != v.end(); it++) { cout << *it << " "; } cout << e

2020-12-23 17:16:14 65

原创 STL(STL初识--vector存放内置数据类型,STL 初识-vector存放自定义数据类型,STL 初识 _容器嵌套容器)

01 STL初识–vector存放内置数据类型#include<iostream>using namespace std;#include<vector>#include <algorithm> //标准算法的头文件/*容器:vector算法:for_each迭代器:vector<int>::iterator*/void MyPrint(int val){ cout << val << endl;

2020-12-22 17:18:49 141

原创 模板 (函数模板语法 ,类模板与函数模板的区别,:函数模板案例,普通函数与函数模板的区别,普通函数与函数模板调用规则,模板的局限性,类模板分文件编写.cpp,Person.hpp,类模板与友元)

01:函数模板语法:#include<iostream>using namespace std;//交换两个整型函数void swapInt(int &a ,int & b){ int temp = a; a = b; b = temp; }//交换两个浮点型函数void swapDouble(double& a, double& b){ double temp = a; a = b; b = temp;}//函数模

2020-12-22 13:52:07 120

原创 cpp (基于多态的职工管理系统)

源文件:职工管理系统.cpp:#include<iostream>#include"WorkerManager.h"#include<string>#include"worker.h"#include"employee.h"#include "manager.h"#include"boss.h"using namespace std;int main(){ //测试代码 /*Worker* worker = NULL; worker = new Emp

2020-12-19 23:54:30 472 3

原创 cpp文本文件(读文件,写文件)

文本文件:1:文件操作必须包含头文件fstream2: 创建流对象:写文件可以利用ofstream,或者fstream类( 读文件 用 ifstream 或者 fstream)3:打开文件时候需要指定操作文件的路径 ,以及打开方式 格式: ofs.open(“文件路径” , 打开方式)4:利用<<可以向文件中写数据 格式: ofs <<“写入数据”5:操作完毕,要关闭文件 格式:ofs.close();打开方式:ios::in 为读文件而

2020-12-17 20:32:06 2853

原创 多态 案例三 (电脑组装)

#include<iostream>using namespace std;//抽象不同零件类//抽象CPU类class CPU{public: virtual void calculate() = 0;};class VideoCard{public: virtual void display() = 0;};class Memory{public: virtual void storage () = 0;};class Compu

2020-12-17 13:49:06 233

原创 cpp多态 (虚析构,纯虚函数)

01:#include<iostream>using namespace std;//制作饮品class AbstactDrinking{public: //煮水 virtual void Boil() = 0; //冲泡 virtual void Brew() = 0; //倒入水中 virtual void PourInCup() = 0; //加入辅料 virtual void PutSomething() = 0; //制作饮品 void makeDr

2020-12-16 13:42:13 312

原创 cpp 多态 (虚函数 纯虚函数 抽象类)

1:地址早绑定 在编译阶段确定函数地址如果想执行让猫说话,那么这个函数地址就不能提前绑定,需要在运行阶段进行绑定,地址晚绑定动态多态满足条件1:有继承关系2:子类重写父类的虚函数重写:返回值类型相同 函数名 参数列表 完全相同动态多态的使用:父类的指针或者引用 指向子类对象#include<iostream>using namespace std;class Animal{public: //虚函数 virtual void speak() { cout &

2020-12-15 18:10:17 234

原创 C++继承与派生

1:子类 需要继承Base和Base2语法: class 子类:继承方式 父类1,继承方式 父类2当父类中出现同名成员,需要加作用域区分#include<iostream>using namespace std;class Base1{ public : int m_A; Base1() { m_A = 100; }};class Base2{ public: int m_A; Base2() { m_A = 200; }};//子类 需要继承

2020-12-14 23:36:58 92

原创 CPP中的继承关系

//继承的好处:减少代码的重复率/**语法:class 子类 :继承方式 父类子类 也称为派生类基类 也称为基类*///继承中的对象模型#include<iostream>using namespace std;class Base{public: int m_A;protected: int m_B;private: int m_C;};class Son :public Base{public: int m_D;};void

2020-12-10 22:55:33 435

原创 内存模型 new运算符操作

1:new运算符操作#include<iostream>using namespace std;int* func(){ //堆区创建整型数据 //new返回是 该数据类型的指针 int* p = new int(10); return p;}void test01(){ int* p = func(); cout << *p << endl; cout << *p << endl; cout << *p

2020-11-27 22:34:48 121 1

原创 通讯录管理系统

#include<iostream>#define MAX 1000using namespace std;#include<string>//设计联系人结构体struct Person{ string m_Name; string m_phone; int m_Sex; int m_Age; string m_Address;};//设计通讯录结构体struct Addressbooks{ //保存联系人数组 struct Person pers

2020-11-26 23:56:40 152

原创 2020-11-26

#include<iostream>#define MAX 1000using namespace std;//设计联系人结构体struct Person{ string m_name; string m_phone; int m_Sex; string m_Addr;};//设计通讯录结构体struct Addressbooks{ //保存联系人数组 struct Person personArray[MAX]; //记录当前联系人的个数 int m_

2020-11-26 16:08:36 171 1

原创 结构体案例二:英雄

#include<iostream>using namespace std;#include<string>//创建结构体struct Hero { string name; int age; string sex;};void bubbleSort(struct Hero HeroArray[],int len) {//冒泡排序 for (int i = 0; i < len-1; i++) { for (int j = 0; j < le

2020-11-25 22:45:22 150

原创 指针

//const的使用场景//#include// using namespace std;//// struct student// {// int age;// };//// //const使用场景// void printStudent(const student *s) //使用指针可以减少内存的开销,不用复制全部数据。加const防止函数体中的误操作// {// cout << “年龄为” << s->age << endl;

2020-11-25 13:40:21 49

原创 C++(值传递,引用传递,地址传递 指针配合函数和数组 结构体 结构体指针)

一:值传递,引用传递,地址传递#include<iostream>using namespace std;//值传递void swap(int a, int b) { int temp = a; a = b; b = temp; cout << "使用值传递a的值为:" << a << endl; cout << "使用值传递b的值为:" << b << endl; cout << "----

2020-11-23 22:58:48 929

原创 分文件编写

在源文件中创建.cpp的源文件#include<iostream>#include"swap.h"using namespace std;void swap(int a, int b)//在源文件中写函数的定义{ int temp = a; a = b; b = temp; cout << "a=" << a << endl; cout << "b=" << b << endl;}int mai.

2020-11-21 18:09:01 267

原创 C++(遍历数组,找最值,交换元素,统计分数)

//三只小猪称体重/*#include<iostream>using namespace std;int main(){ int arr[5] = { 12,18,11,16,10 }; int max = 0; for (int i = 0; i < 5; i++) { if (arr[i] > max) { max = arr[i]; } } cout << "最重的猪的体重为:" << max <

2020-11-20 22:31:12 456

原创 2020-11-17

#include<iostream>using namespace std;const float PI = 3;class Circle {public: Circle(float r); //构造函数 float area(); //成员函数private: float radius;}; float Circle::Circle(float r){//成员函数的实现 float radius; radius = r; retur

2020-11-17 21:40:22 46

原创 2020-11-16

/*静态成员变量两种访问方式1:通过对象类名 对象名;对象名.函数名;2:通过类名类名::函数名;*/#include <iostream>using namespace std;class Person {public : static int m_A; int m_B; /*静态成员函数的特点 * 1:程序共享一个函数 * 2:静态成员函数只能访问静态成员变量 */ static void func() { cout << "fu

2020-11-16 17:39:44 41

原创 C++

/*//4-9#include<iostream>using namespace std;class Rectangle { // 设计一个矩形类public: void setX1(int x1) { m_X1 = x1; } int getX1() { return m_X1; } void setY1(int y1) { m_Y1 = y1; } int getY1() { return m_Y1; } void setX2(int x2)

2020-11-15 23:43:25 90

原创 Java 第19 天(遍历字符串 统计字符串 拼接字符串 字符串反转)

//遍历字符串import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;import java.sql.SQLOutput;import java.util.Scanner;public class StringDemo{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); Syste.

2020-11-12 16:06:16 156

原创 2020-11-11 Java第18天(String 概述,字符串的比较,遍历字符串)

在这里插入图片描述package com.itheima_02;/*String 构造方法:public String(),创建一个空白字符串对象,不含任何内容public String(char[[] chs),根据字符数组的内容,来创建字符串对象public String (byte[] bys).根据字节数组的内容,来创建字符串对象String s = “abc”; 直接赋值的方式创建字符对象,内容就是abc。*/public class StringDemo { ...

2020-11-12 12:59:40 137 2

原创 Java 第十七天(封装,this private 关键字 构造方法,标准类的制作,API的使用)

对象的使用1:创建对象格式:类名 对象名=new 类名();范例:phone p = new phone();2:使用对象(1):使用成员变量格式:对象名.变量名范例:p.brand(2):使用成员方法格式:对象名.方法名()范例:p.call()*//*public class Phone { //成员变量 String brand; //String类型是字符串的对象包装类型 int price; //成员方法 pu...

2020-11-10 23:28:54 646 1

原创 Java第16天 (类的定义和对象的使用)(学生类,phone类)

public class Phone { //成员变量 String brand; //String类型是字符串的对象包装类型 int price; //成员方法 public void call (){ System.out.println ("打电话"); } public void sendMessage(){ System.out.println("发短信"); }}/*创建对象格式:类名

2020-11-08 23:13:14 1279

空空如也

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

TA关注的人

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