- 博客(10)
- 收藏
- 关注
原创 自定义一个动态数组
// // main.cpp // Xcode/Cplusplus // // Created by zforw on 2021/3/2. // #include <iostream> #include <algorithm> using namespace std; template <typename Type> class VLA{ public: VLA(){ _size = 0; elem = nullptr;.
2021-03-03 19:36:22
124
原创 2020/12/18第三次上机
T1 #include<iostream> using namespace std; class Fraction { //数据成员,访问控制属性默认是私有 int m_numerator = 0; // 分子默认为0; C++11 int m_denominator = 1; //分母默认为1; public://公有成员函数 Fraction(int above = 0, int below = 1) : m_numerator(above), m_denom
2020-12-18 20:52:15
235
1
原创 面向对象
真∙面向对象 Object Oriented Programming class class_name { instance varibles public: member_functions private: ... }; class_name obj_name()//generate_function obj_name.xxx 特性 继承 区别于Java,可以继承多个类 class C:public A,public B { }; 封装 多态 接口 class Base.
2020-12-15 22:23:17
183
1
原创 排序
排序算法 冒泡排序 O(n^2) 通过比较来交换相邻的两个数,每一次遍历一定会将当前范围内最大的移动到最后(如果是最大的,每一比较相邻的两个元素它都是最大值,逃不掉的)。 称做冒泡的原因:越小的元素会经由交换慢慢“浮”到数列的首端,就如同水中的气泡最终会上浮到顶端一样。 //Increase void bubble_sort(int a[],int l,int r) { for(int i = l;i < r;++i) { for(int j = i;j <=
2020-12-11 20:13:38
167
原创 2020/12/05第二次上机题目
一、交换矩阵的行 #include <iostream> using namespace std; const int MAX_SIZE = 101; int mat[MAX_SIZE][MAX_SIZE],n,m,max_sum,row; int main() { m = 3,n=4; max_sum = -2147483648; for(int i = 1;i <= m;++i){ for(int j = 1;j <= n;++j){
2020-12-05 20:25:45
204
1
原创 指针常量与常量指针
常量指针 偏正短语,是个常量修饰指针(指向const 对象的指针,不能通过该指针修改对象的值) 可以改变指向 const int *p; int const *p; const int cj = 1; int ci = 0;//也可以没有const //指向const对象指针要加const const int *pc = &cj; //不可以通过pc修改cj的值 const int *pt = &ci; 指针常量 不可以改变指向 int *const cp = &ci; 指向常
2020-11-24 12:57:27
116
原创 2020/11/11第一次上机题目
一、排序 // // Created by 赵丰 on 2020/11/11. // #include<iostream> #include<cmath> using namespace std; int main(){ int a,b,c; cin>>a>>b>>c; if(a > b){ if(a < c){ int t = c; c = a;
2020-11-11 19:34:34
1212
5
原创 「CF1264A」A. Beautiful Regional Contest
p????️ > p ???? > p ???? g + s + b <= n / 2 g < s , g < b maximize g + s + b 尽可能使金牌最少(多个答案输出一种) : a[1] #include <iostream> #include <cstring> #include <ctime> #include <algorithm> using namespace std; int p[400100],t,
2020-10-27 14:45:39
224
原创 「CF1430C」 Numbers on Whiteboard
Numbers 1,2,3…n(each integer from 1 to n once) are written on a board. In one operation you can erase any two numbers a and bfrom the board and write one integer a+b2 \frac {a+b}{2} 2a+b rounded up instead. You should perform the given operation n - 1 tim
2020-10-25 22:27:48
299
1
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人