![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++基础
sinat_15355869
这个作者很懒,什么都没留下…
展开
-
Iterative Depth First Traversal of Graph
C++ -> DFS 【1】#include <list>#include <stack>#include <vector>#include <iostream>using namespace std;class Graph { int V; list<int> *adj;public: explicit Graph(int V); void addEdge(int v, int w)原创 2022-02-27 00:56:12 · 108 阅读 · 0 评论 -
explicit 用法提醒
参考链接:C++ 关键字 explicit 的使用隐式转换,如何消除隐式转换?Clion提示:Single-argument constructors must be marked explicitly to avoid unintentional implicit conversions 解法办法https://www.cplusplus.com/doc/tutorial/typecasting/什么时候会 explicit:C++面向对象的多态特性,就是通过父类的类型实现对子原创 2022-02-07 00:00:36 · 455 阅读 · 0 评论 -
Find if there is a path between two vertices in an undirected graph
如图:python bfs 预热 (简单粗暴)# 无向图的的两个节点是否相连 ~ :from collections import dequedef addEdge(v, w): global adj adj[v].append(w) adj[w].append(v)def isReachable(s, d, V): if (s == d): return True visited = [False for i in range原创 2022-02-06 01:12:27 · 608 阅读 · 0 评论 -
Find if there is a path between two vertices in a directed graph
基础遍历预热#include <iostream>#include <vector>#include <stack>#include <algorithm>using namespace std;struct TreeNode { int val; TreeNode* left; TreeNode* right; TreeNode(int x): val(x), left(nullptr), right(..原创 2022-02-04 19:05:10 · 708 阅读 · 0 评论 -
7 Class Templates array and vector; Catching Exceptions
目录:array -> Sorting and searching arrays. vector -> Demonstrating C++ Standard Library class template vector.1. array -> Sorting and searching arrays.// array -> sorting and searching#include <iostream>#include <iomanip>原创 2021-12-18 10:58:55 · 837 阅读 · 0 评论 -
6 Functions and an Introduction to Recursion
目录:1、maximum function with a function prototype.2、Shifted, scaled integers produced by 1 + rand() % 6.3、Demonstrating srand (随机种子)4、Random Number (优点)5、Inline Functions6、References and Reference Parameters7、Using default arguments8、Unary sc原创 2021-12-14 13:47:15 · 131 阅读 · 0 评论 -
5 Control Statements: Part 2; Logical Operators
概述:Chapter 4 discussed if, if…else and while. This chapter demonstrated for, do…while and switch.You used the break statement to exit a switch statement and to immediately terminate a loop, and used a continue statement to terminate a loop’s current ..原创 2021-12-11 19:24:59 · 437 阅读 · 0 评论 -
4 A lgorithm Development and Control Statements: Part 1
1、Only three types of control statements—sequence, selection and iteration—are needed to develop any algorithmmain.cpp#include <iostream>#include <iomanip>using namespace std;int main() { int total{0}; unsigned int gradeCoun..原创 2021-12-11 16:31:13 · 438 阅读 · 0 评论 -
3 Introduction to Classes, Objects, Member Functions and Strings
目录:1、created your own classes and member functions2、create UML class diagrams that model the member functions, attributes and constructors of classesAccount.h#ifndef UNTITLED1_ACCOUNT_H#define UNTITLED1_ACCOUNT_H#include <string>#incl原创 2021-12-11 15:55:13 · 186 阅读 · 0 评论 -
cmake - 02 - subprojects
参考链接????:GCC全过程详解+剖析生成的.o文件CMAKE 里PRIVATE、PUBLIC、INTERFACE属性示例详解cmake:target_** 中的 PUBLIC,PRIVATE,INTERFACE1. 指令说明target_include_directories():指定目标包含的头文件路径。官方文档target_link_libraries():指定目标链接的库。官方文档target_compile_options():指定目标的编译选项。官方文档目标 由原创 2021-10-21 07:31:54 · 138 阅读 · 0 评论 -
cmake - 01K - imported-targets
目录:文件:run_test.sh#!/bin/bashcmake_version=`cmake --version | grep version | cut -d" " -f3`[[ "$cmake_version" =~ ([3-9][.][5-9.][.][0-9]) ]] || exit 0echo "correct version of cmake"mkdir -p build && cd build && cmake .. &am原创 2021-10-21 06:25:12 · 228 阅读 · 0 评论 -
cmake - 01H - third_party_library
目录:文件:main.cpp#include <iostream>#include <boost/shared_ptr.hpp>#include <boost/filesystem.hpp>int main(int argc, char *argv[]){ std::cout << "Hello Third Party Include!" << std::endl; boost::shared_ptr原创 2021-10-16 16:42:14 · 133 阅读 · 0 评论 -
cmake - 01E - installing
目录:(base) ➜ cmaker_learning tree.├── CMakeLists.txt├── build├── cmake-examples.conf├── include│ └── installing│ └── Hello.h└── src ├── Hello.cpp └── main.cpp4 directories, 5 files文件:与之前相同重点是 CMakeLists.txtcmake_min...原创 2021-10-16 13:41:25 · 85 阅读 · 0 评论 -
cmake - 01D - shared-library
动态链接目录:文件:Hello.h#ifndef CMAKER_LEARNING_HELLO_H#define CMAKER_LEARNING_HELLO_Hclass Hello{public: static void print();};#endif //CMAKER_LEARNING_HELLO_HHello.cpp#include <iostream>#include "../include/shared/Hello.h"u.原创 2021-10-16 12:18:47 · 57 阅读 · 0 评论 -
cmake - 01C - static-library
目录结构文件:Hello.h#ifndef CMAKER_LEARNING_HELLO_H#define CMAKER_LEARNING_HELLO_Hclass Hello{public: void print();};#endif //CMAKER_LEARNING_HELLO_HHello.cpp#include <iostream>#include "static/Hello.h"using namespace std;vo原创 2021-10-16 11:49:22 · 62 阅读 · 0 评论 -
cmake - 01 - hello-headers
目录:cmake 复习一下文件结构:(两个实验)文件内容:Hello.h#ifndef CMAKER_LEARNING_HELLO_H#define CMAKER_LEARNING_HELLO_Hclass Hello{public: void print();};#endif //CMAKER_LEARNING_HELLO_HHello.cpp#ifndef CMAKER_LEARNING_HELLO_H#define CMAKE.原创 2021-10-16 11:09:48 · 66 阅读 · 0 评论 -
19 - Custom Templatized Data Structure
目录:1. List1. List 定义//// Created by on 2021/7/23.//#ifndef PRACTICE15_LIST_H#define PRACTICE15_LIST_H#include <iostream>#include "ListNode.h"using namespace std;template<typename NODETYPE>class List{public: bool isE原创 2021-07-23 16:32:59 · 94 阅读 · 0 评论 -
17 Exception Handling
目录:example that throw exception Rethrowing an exception xxx xx xxx xxx xx1.example that throw exception// example that throw exception#include <iostream>#include "DivideByZeroException.h"using namespace std;double quotient(i...原创 2021-05-16 09:13:24 · 106 阅读 · 0 评论 -
16 Standard Library Algorithms
目录:lambda expressions xxxx xx xxx xxx1.lambda expressions// lambda expressions#include <iostream>#include <array>#include <algorithm>#include <iterator>using namespace std;int main() { const siz...原创 2021-05-04 16:05:49 · 110 阅读 · 0 评论 -
15 standard library containers and iterators
目录:demonstrating input and output with iterators xx xx xxdemonstrating input and output with iterators原创 2021-04-30 17:46:30 · 105 阅读 · 1 评论 -
14 file processing
目录:Creating a sequential file Reading and printing a sequential file credit inquiry program1)Creating a sequential file// Creating a sequential file#include <iostream>#include <string>#include <fstream>#include <cstdlib..原创 2021-04-22 02:06:02 · 114 阅读 · 0 评论 -
13 stream Input/Output -1
很久没写了,今天是4月13号,难得有时间安静的坐下来写写,挺开心的~目录: Using Member Functions eof, get and put Comparing cin and cin.get 1) Using Member Functions eof, get and put#include <iostream>using namespace std;int main() { int character; cout &l.原创 2021-04-13 22:53:15 · 149 阅读 · 0 评论 -
fib c++
#include <iostream>#include "vector"using namespace std;//int fib(int N){// if (N == 1 || N == 2) return 1;// return fib(N-1) + fib(N-2);//}//int helper(vector<int>&...原创 2020-05-06 09:02:38 · 565 阅读 · 0 评论 -
STL sort 最基本
#include <iostream>#include <functional>#include <algorithm>#include <vector>using namespace std;class myclass{public: myclass(int a, int b): first(a), second(b){}...原创 2019-08-07 11:33:54 · 97 阅读 · 0 评论 -
【转】C++ 中vector的使用方法
【转】原 C++ 中vector的使用方法 作者:那年聪聪转载 2019-07-25 11:53:50 · 87 阅读 · 0 评论 -
c++ 友元
记录下#include <iostream>#include <math.h>using namespace std;class Point; // 前向声明class PointManagement{public: double getDistance(Point & a, Point & b);};class P...原创 2019-06-14 09:24:18 · 254 阅读 · 0 评论 -
不要返回局部变量的引用
#include <iostream>using namespace std;// 不要返回局部变量的引用int& sum(){ int num = 10; int& rNum = num; // rNum 是局部变量的引用 return rNum;}void test(){ int x = 1; int y ...原创 2019-04-01 07:54:45 · 741 阅读 · 0 评论 -
c++ 指针 引用 基础
#include <iostream>using namespace std;void swap1(int, int);void swap2(int*, int*);void swap3(int&, int&);void show(const int&, const int&);void swap1(int num1, int nu...原创 2019-04-01 07:09:55 · 157 阅读 · 0 评论