邓俊辉

邓俊辉 MOOC 数据结构 ~ 预备知识 ~ C++ 语言程序设计基础:类、继承、重载、重写、虚方法、模板

戏子无情 提交于 2020-03-09 15:24:13
Class A class is a user-defined type. https://en.cppreference.com/w/cpp/language/classes Inheritance The capability of a class to derive properties and characteristics from another class is called Inheritance. 一个类从另一个类派生属性和特性的能力称为继承 https://en.cppreference.com/w/cpp/language/derived_class Overload 重载 functions can have the same name but different type of parameters and different number of parameters. Operating overloading allows us to make operators work for user-defined classes 同一作用域中,同名函数的形式参数(指参数的个数、类型或者顺序)不同时,构成函数重载。 应用:操作符重载,为用户定义类型的操作数定制 C++ 运算符 Operator overloading is an example of C++

邓俊辉老师数据结构--zuma编程题

天大地大妈咪最大 提交于 2019-11-27 07:31:10
题目: https://dsa.cs.tsinghua.edu.cn/oj/problem.shtml?id=1143 第一次提交95,居然是case2错了, 仔细检查一下,发现创建链表出错了,没有考虑开始时是空链表的情况,检查完后就ok了。 100分代码如下, #include <cstdio> #include<string.h> using namespace std; struct zuma{ char a; zuma* pre; zuma* next; }*head,*tail,*pos; int reduce(char a1){ if(pos==tail)return 0; zuma *p=pos,*q=pos,*r; int i=0,j=0; while(p->pre&&p->pre->a==a1){p=p->pre;i++;} while(q->next&&q->next->a==a1){q=q->next;j++;} if(i+j>1){ r=p; p=p->pre; q=q->next; p->next=q; q->pre=p; if(p!=head)pos=p; else pos=p->next; while(r!=q){p=r;r=r->next;if(p!=head||p!=tail)delete(p);} return 1; } return 0; }