- 博客(15)
- 收藏
- 关注
转载 5-1 继承与派生
#include using namespace std;class Point{private: float X,Y;public: Point(float a = 0,float b = 0) { X = a; Y = b; } void Move(float xOff,float yOff) {
2017-12-28 10:03:11 167
转载 4-1 复数类的运算符重载--成员运算符重载、友元运算符重载
#include using namespace std;class Complex{ private: double real; double imag; public: Complex(double a = 0,double b = 0)//构造函数 { real = a; imag = b; }
2017-12-26 10:42:10 375
原创 对象指针
#include using namespace std;class student{private: string ID; int score;public: void inset() { cin>>ID>>score; } string show1() { return ID; }
2017-12-25 20:46:38 147
原创 类对象数组
#include using namespace std;class student{private: string ID; int score;public: void inset() { cin>>ID>>score; } void outset() {
2017-12-25 19:58:05 518
原创 3-7 类的友元函数的应用
#include using namespace std;class Point{private: double x,y;public: Point(double a = 0,double b = 0) { x = a; y = b; } void showPoint1() { cout<
2017-12-25 17:39:56 148
翻译 3-6 静态数据成员与静态成员函数
#include using namespace std;class Point{private:double x,y;//数据成员static int count1;//静态数据成员countpublic:Point(double a = 0,double b = 0)//构造函数,设置其默认值为0,在未输入值时执行构造函数时输出为0{x = a;
2017-12-25 17:14:27 176
原创 数据结构实验之排序五:归并求逆序数
#include using namespace std;long long int cnt; //逆序数可能是个数值很大的数字,用long long int.void Merge(int a[], int l, int mid, int r) //归并:进来一个无序数组(已用mid进行了二分,一直mid、l、r)将进来的分为两部分的数组进行排序,后存入新开的t数组中{
2017-12-24 10:42:07 250 1
原创 数据结构实验之排序三:bucket sort 桶排序
#include using namespace std;int main(){ ios::sync_with_stdio(false);//用c++读入超时 int n; cin>>n; int i,a[101],x; memset(a,0,sizeof(a)); for(i = 0;i <= n - 1;i++) {
2017-12-23 22:28:18 385
原创 数据结构实验之排序二:交换排序
#include using namespace std;int cnt1,cnt2;int Partition(int a[],int low,int high){ int key = a[low]; a[0] = a[low]; while(low < high)//基于赋值排序时,当找到枢纽时 { while(low = key)//当
2017-12-23 22:02:51 193
原创 数据结构实验之排序一:一趟快排
#include using namespace std;void Partition(int a[],int low,int high){ int key = a[low]; a[0] = a[low]; while(low < high) { while(low = key) high--; a[low]
2017-12-23 21:11:56 256
原创 数据结构实验之查找七:线性之哈希表
#include using namespace std;int Hash(int num,int p){ int k; k = num % p; return k;}int main(){ int n,p; while(cin>>n>>p) { int i,a[2000],num,k; memset(a
2017-12-23 19:33:10 176
原创 数据结构实验之查找五:平方之哈希表
//哈希表:建立元素与数组下标的联系#include using namespace std;int cnt;int Hash(int num,int p){ int k; k = num % p; return k;}int main(){ ios::sync_with_stdio(false); int n,p; while(
2017-12-23 00:11:23 137
转载 数据结构实验之查找二:平衡二叉树
#include typedef int Elemtype;typedef struct BiTNode{ Elemtype data; int depth; struct BiTNode *lchild; struct BiTNode *rchild;}BiTNode,*BiTree;int max(int x,int y) //找两个数中的较大
2017-12-21 23:15:57 177
转载 数据结构实验之查找一:二叉排序树
#include using namespace std;int cnt;typedef struct BiTNode{ int data; struct BiTNode *lchild; struct BiTNode *rchild;} BiTNode,*BiTree;BiTree Create(BiTree T,int x){ if(T == N
2017-12-21 22:21:12 155
转载 3-5 学生成绩统计
#include using namespace std;class student{private: int num,m,e,c; string name;public: int Sum(int m,int e,int c) { return m+e+c; } double Avg(int sum) {
2017-12-16 23:13:10 231
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人