C++基础
philosophia_OsO
这个作者很懒,什么都没留下…
展开
-
课程作业——数据结构与算法C++(1)
课程作业6(归并排序 冒泡排序 插入排序 选择排序) /*归并排序 冒泡排序 插入排序 选择排序*/ //主程序 #include<iostream> #include<vector> using std::vector; using std::cout; using std::endl; using std::swap; #include"bubble_sort.h" #...原创 2020-06-20 23:54:13 · 81 阅读 · 0 评论 -
课程作业——数据结构与算法C++
1.两种实现方法 //数组实现 #pragma once #ifndef _ARRAYSTACK_H_ #define _ARRAYSTACK_H_ const int SIZE = 1024; template <typename dataType> class arrayStack { private: dataType buffer[SIZE]; int index; pub...原创 2020-06-20 23:53:33 · 89 阅读 · 0 评论 -
C++基础之基础
C++(容纳了好几种编程范式):面向对象编程、泛型编程、过程化编程 ------面向对象编程:其本质是以建立模型体现出来的抽象思维过程和面向对象的方法。 抽象、继承、多态: 抽象性是指将具有一致的数据结构(属性)和行为(操作)的对象抽象成类。一个类就是这样一种抽象,它反映了与应用有关的重要性质,而忽略其他一些无关内容。任何类的划分都是主观的,但必须与具体的应用有关。(使用抽象,你可以用有限的属性...原创 2020-05-28 21:41:30 · 80 阅读 · 0 评论 -
if/switch的区别
原创 2019-02-20 22:40:02 · 230 阅读 · 0 评论 -
while/do while/for/goto的区别
//Calculate 1+2+3+…+100原创 2019-02-20 22:37:39 · 550 阅读 · 0 评论 -
数组与指针的区别
1 Array and Pointer int *a1[3] :It is an array, each element is a pointer int (*a2)[3] : It is a pointer. It points to an array with 3 elements 2 Array and Pointer int a[10]={1,2,3}; int *b=a; b++;...原创 2019-02-20 22:07:32 · 70 阅读 · 0 评论 -
模板template的使用
//C++与C的不同点 :模板template的使用 #include &lt;iostream&gt; //无需加上".h " using namespace std;//使用命名空间 template&lt;typename T&gt; //定义模板类型 T f(T &amp;a,T &amp;b){ return a&gt;b?a:b; } in原创 2019-02-20 15:56:39 · 160 阅读 · 0 评论 -
最大子序列和问题
//最大子序列和问题Maximum Subsequence Sum #include <iostream> #include<vector> using namespace std;//使用命名空间 /*************T(N)=O(N^3) Cubic************/ int maxSubSum1(const vector<int> ...原创 2019-02-25 23:40:05 · 91 阅读 · 0 评论 -
Fibonacci的四种求解方法
//Fibonacci Sequence的使用 #include <iostream> using namespace std;//使用命名空间 /*************T(N)=O(N^2)=T(N-1)+T(N-2)+2************/ int fib2(int n){ if(n<=1)return n; else return fib2(n-1)+f...原创 2019-02-25 21:56:13 · 199 阅读 · 0 评论 -
STL中vector的使用
STL中vector //vector的使用 #include <iostream> #include<vector> using namespace std;//使用命名空间 int main(){ vector<int> v1; vector<double> v2(10); vector<double> v3(v2); ...原创 2019-02-25 19:55:00 · 166 阅读 · 0 评论 -
Structure and Class (结构体与类)
原创 2019-02-23 10:27:19 · 355 阅读 · 0 评论 -
类的应用示例+继承
//类的应用示例 #include &lt;iostream&gt; using namespace std;//使用命名空间 class student{ /****constructor initializer list 构造函数初始化列表****/ public: student():stu_num(0),stu_score(0){} student(int num):stu...原创 2019-02-21 23:08:31 · 444 阅读 · 0 评论 -
Function pointer and pointer function指针函数和函数指针
//指针函数 int *f(int x, int y){} //pointer function //f is a function, it returns a pointer //函数指针 int (*f)(int x, int y){} //function pointer //f is a pointer, it points to a function 程序示例 //函数指针的使用 ...原创 2019-02-21 22:18:15 · 300 阅读 · 0 评论