cpp-vector vector cpp

pta_【CPP0039】vector应用测试

#include<iostream>#include<vector>#include<algorithm>using namespace std;int main(void){ int i,a[10],b; for(i=0; i<10; i++){ scanf("%d",&a[i]); } scan ......
vector 0039 pta CPP

IO库和string、vector

IO 库重载了移位运算符 C++并没有函数输出,而是奇怪的运算符scanf() printf() 实际上cin他们是一个类的对象 干脆禁止拷贝,因为要管理缓冲区,防止冲突 <<移位有左结合性,所以具体应该是(cout<<a)<<b 前面应该返回一个cout 细度 第一个参数是ostream 对象,因 ......
string vector

pta_【CPP0036】利用函数模板解决双倍功能

#include <iostream>using namespace std; template <typename T>T Double(T num){ return 2.0 * num;} int main(void){ char c='\0'; int i=0; long l=0; scanf ......
双倍 函数 模板 功能 0036

每日打卡c++中vector容器使用

首先头文件#include<vector> for_each一种算法需要头文件#include<algorithm>标准算法头文件 vector<int>::iterator迭代器,可以当指针用。 基本格式vector<数据类型>名称;数据类型可以是类。 例子 #include<iostream># ......
容器 vector

学生CPP成绩计算

一、问题描述。 计算学生的CPP成绩 二、设计思路。 定义下面的人员基类框架: class Person{ protected: string name; int age; public: Person(); Person (string p_name, int p_age); void displ ......
成绩 学生 CPP

vector容器(上)

一、基本概念 (1)vector数据结构和数组非常相似,也称为单端数组;; (2)vector容器可以动态扩展(并不是在原空间之后续接新空间,而是找更大的内存空间,然后将原数据拷贝新空间,释放原空间; 二、构造函数 (1)函数原型: ①vector<T> v;//采用模板实现类实现,默认构造函数; ......
容器 vector

学生CPP成绩计算

学生CPP成绩计算 给出下面的人员基类框架: class Person { protected: string name; int age; public: Person(); Person (string p_name, int p_age); void display () {cout<<nam ......
成绩 学生 CPP

OpenGL学习笔记-3:编译shader报错: cannot convert from 'const highp float' to 'FragUserData 4-component vector of highp float'

报错信息: ERROR::SHADER_COMPILATION_ERROR of type: FRAGMENTERROR: 0:10: 'assign' : cannot convert from 'const highp float' to 'FragUserData 4-component ve ......
float highp 39 FragUserData component

cpp: Struct Simple

// DuStudent.h : 此文件包含 "DuStudent" 类。策略模式 Strategy Pattern C++ 14 // 2023年5月1日 涂聚文 Geovin Du Visual Studio 2022 edit. #pragma once #ifndef DUSTUDENT_H ......
Struct Simple cpp

23-5-8--vector--数组循环左移

本题要求实现一个对数组进行循环左移的简单函数:一个数组a中存有n(>0)个整数,在不允许使用另外数组的前提下,将每个整数循环向左移m(≥0)个位置,即将a中的数据由(a0​a1​⋯an−1​)变换为(am​⋯an−1​a0​a1​⋯am−1​)(最前面的m个数循环移至最后面的m个位置)。如果还需要考 ......
数组 vector 23

pta_【CPP0027】以圆类Circle及立体图形类Solid为基础设计球类Sphere

#include <iostream>using namespace std;//点类Pointclass Point{private: double x; double y;public: Point(double xv=0,double yv=0);/*构造函数*/ Point(const Po ......
球类 立体 图形 基础 Circle

删除 vector 中引用指向的元素,会有什么结果?

#include <iostream> #include <vector> int main() { std::vector<int> arr = {1, 2, 3}; const int &a = arr[0]; std::cout << a << '\n'; arr.erase(arr.begi ......
指向 元素 结果 vector

cpp: 内存地址

在 Visual Studio 调试器中使用“内存”窗口(C#、C++、Visual Basic、F#) 在调试器中查看变量的内存 - Visual Studio (Windows) | Microsoft Learn int a = 10; char b; bool c; string d; co ......
内存 地址 cpp

C++容器(vector、deque、list、map)

##(1) vector:将元素置于一个动态数组中,可以随机存储元素(也就是用索引直接存取)。 数组尾部添加或删除元素非常迅速。但在中部或头部就比较费时。 *代码演示:* 取: at在下标越界时会抛出异常,我们能捕获异常进行处理;而[]下标越界会让程序直接终止; 构造函数: cbegin, cend ......
容器 vector deque list map

pta_【CPP0026】以点类Point及平面图形类Plane为基础设计三角形类Triangle

#include <iostream>#include<cmath>using namespace std;//点类Pointclass Point{private: double x; double y;public: Point(double xv=0,double yv=0);/*构造函数*/ ......
三角形 Triangle 图形 平面 基础

6-4 【CPP0026】以点类Point及平面图形类Plane为基础设计三角形类Triangle

6-4 【CPP0026】以点类Point及平面图形类Plane为基础设计三角形类Triangle 分数 10 作者 C++多态编程 单位 石家庄铁道大学 以平面图形类Plane为基类公有派生三角形类Triangle,main(void)函数完成对其的测试。 Point类结构说明: Point类的数 ......
三角形 Triangle 图形 平面 基础

cpp: Strategy Pattern II

// Gold.h : 此文件包含 "Gold" 类。策略模式 Strategy Pattern C++ 14 // 2023年5月1日 涂聚文 Geovin Du Visual Studio 2022 edit. #pragma once //#ifndef GOLD_H //#define GO ......
Strategy Pattern cpp II

cpp: Strategy Pattern

// Gold.h : 此文件包含 "Gold" 类。策略模式 Strategy Pattern C++ 14 // 2023年5月1日 涂聚文 Geovin Du Visual Studio 2022 edit. #pragma once //#ifndef GOLD_H //#define GO ......
Strategy Pattern cpp

pta_【CPP0024】设计并实现大数类BigNum

#include <iostream>using namespace std;#define N 100 #include<cstring> class BigNum{private: char num[N];public: BigNum(char c[N] = "+0") { int i,j,a ......
大数 BigNum 0024 pta CPP

数组与vector容器

数组存放在栈区,vector容器存放在堆区 定长容量较小时使用数组,此时数组性能较好,变长容量较大或则不确定容量时使用容器 常常习惯用迭代器来访问vector而非下标,但是当vector为二维时最好用下标来访问,因为这样可以自由的访问每个元素,而迭代器只能一行一行的访问。比如牛客的这道题:显然用下标 ......
数组 容器 vector

C++用return{}来返回空的Vector数组

本人在刷Leecode题目的时候发现以下代码 class Solution { public: std::unordered_map <int,int> map; for(int i = 0; i < nums.size(); i++) { // 遍历当前元素,并在map中寻找是否有匹配的key a ......
数组 return Vector

极速进化,光速转录,C++版本人工智能实时语音转文字(字幕/语音识别)Whisper.cpp实践

业界良心OpenAI开源的Whisper模型是开源语音转文字领域的执牛耳者,白璧微瑕之处在于无法通过苹果M芯片优化转录效率,Whisper.cpp 则是 Whisper 模型的 C/C++ 移植版本,它具有无依赖项、内存使用量低等特点,重要的是增加了 Core ML 支持,完美适配苹果M系列芯片。 ......
语音 人工智能 光速 字幕 实时

cpp: Builder Pattern

// Gold.h : 此文件包含 "Gold" 类。原型模式 Builder Pattern C++ 14 // Jewelry Builder Pattern 生成器模式 建造者模式、Builder // 2023年5月1日 涂聚文 Geovin Du Visual Studio 2022 ed ......
Builder Pattern cpp

cpp: Prototype Pattern

// Gold.h : 此文件包含 "Gold" 类。原型模式 Prototype Pattern C++ 14 // 2023年5月1日 涂聚文 Geovin Du Visual Studio 2022 edit. #pragma once #ifndef GOLD_H #define GOLD_ ......
Prototype Pattern cpp

cpp: Abstract Factory Pattern

// Gold.h : 此文件包含 "Gold" 类。Abstract Factory Pattern C++ 14 // 2023年4月30日 涂聚文 Geovin Du Visual Studio 2022 edit. #pragma once #ifndef GOLD_H #define GO ......
Abstract Factory Pattern cpp

cpp multi thread std::lock_guard,mutex

#include <atomic> #include <chrono> #include <cmath> #include <condition_variable> #include <ctime> #include <fstream> #include <functional> #include ......
lock_guard thread multi guard mutex

cpp multi thread sync via std::atomic<bool>

#include <atomic> #include <chrono> #include <cmath> #include <condition_variable> #include <ctime> #include <fstream> #include <functional> #include ......
atomic thread multi bool sync

cpp: Simple Factory Pattern

// Monster.h : 此文件包含 "Monster" 类。Abstract Factory Pattern C++ 14 // 2023年4月29日 涂聚文 Geovin Du Visual Studio 2022 edit. #pragma once #ifndef MONSTER_H # ......
Factory Pattern Simple cpp

cpp: Template Mothod Pattern

文章来源《C++新经典设计模式》 王健伟编著 清华大学出版社 // TemplateMethonPattern.h : 此文件包含 "TemplateMethonPattern" 类。Template Mothod Pattern C++ 14 // 2023年4月29日 涂聚文 Geovin Du ......
Template Pattern Mothod cpp

cpp future,get,sleep_for,third variable

#include <chrono> #include <condition_variable> #include <ctime> #include <fstream> #include <future> #include <iomanip> #include <iostream> #include ......
sleep_for variable future sleep third