自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(62)
  • 收藏
  • 关注

原创 mysql 子查询

子查询什么是子查询?子查询都可以出现在哪里?案例:找出高于平均工资的员工mysql> select avg(sal) from emp;+-------------+| avg(sal) |+-------------+| 2073.214286 |+-------------+1 row in set (0.00 sec)mysql> select ename,sal from emp where sal> 2073.214286;+-------+----

2022-02-10 10:52:11 509 1

原创 distinct 去重复记录 mysql

关于查询结果集的去重? distinctmysql> select distinct job from emp;+-----------+| job |+-----------+| CLERK || SALESMAN || MANAGER || ANALYST || PRESIDENT |+-----------+5 rows in set (0.00 sec)/*两个字段联合去重*/mysql> select distinct dept

2022-02-10 10:50:58 263

原创 mysql 连接查询

mysql 连接查询

2022-02-10 10:50:12 785

原创 Mysql

mysql 简介

2022-02-10 10:49:25 246

原创 group by 和 having

group by 和 having的用法

2022-02-10 10:47:05 346

原创 c++ 单继承派生类构造函数

#include<iostream>using namespace std;class B{public: B();//构造函数 B(int i);//带一个参数的构造函数 ~B();//析构函数 void printf()const;//不改变对象状态 定义成const函数 private: int b; };B::B(){b=0;cout<&...

2018-10-16 20:00:00 421

原创 c++ 私有继承

#include<iostream>using namespace std;class Point{public: void initPoint(float x = 0,float y = 0){ this->x = x; this->y = y; } void move(float offx,float offy){ x += offx; y +...

2018-10-15 21:10:21 204

原创 c++共有继承

#include<iostream>using namespace std;class Point{public: void initPoint(float x = 0,float y = 0){this->x = x;this->y = y; } void move(float offX, float offY) {x += offX;y += offY;

2018-10-15 19:47:40 233

原创 动态分配内存完成矩阵转置

#include<iostream>using namespace std;void swap(int &a,int &b){int temp = a;a = b;b = temp;}int main(){int **a; //指向一个地址的指针 a = new int *[3];//指针数组 for(int i = 0;i < 3;i+...

2018-10-15 14:45:45 1047

原创 string类getline函数的简单运用

#include<iostream>#include<string>using namespace std;int main(){for (int i=0;i < 3 ;i++){ string city,provice,state; getline(cin,city,',');//getline可以输入整行的字符串,第三个参数表示已','为结束,默认...

2018-10-15 13:24:53 994

原创 string 类的简单运用

#include<stdio.h>#include<string>#include<iostream>using namespace std;//根据value的值输出ture或者false//title为提示文字inline void test(const char *title,bool value){cout <<title ...

2018-10-15 12:57:26 139

原创 c++ 动态数组类的创建和简单运用

#include<iostream>#include<cassert>using namespace std;class Point{public:Point(int x,int y):x(x),y(y){ cout<<"调用构造函数"<<endl;}Point():x(0),y(0){ cout<<"调用默认构造函.

2018-09-20 21:15:43 5178

原创 c++ vector的应用举例

//调用含有普通的非引用vector形参的函数会复制vector的每一个元素#include<iostream>#include<vector> using namespace std;double average(const vector <double>&arr){double sum = 0;for(unsigned i = 0;i&...

2018-09-20 19:38:06 717

原创 c++动态分配空间创建三维数组

#include<iostream>using namespace std;int main(){int (*cp)[9][8] = new int [7][9][8];//创建一个动态的三维数组for (int i = 0;i<7;i++)//给数组的每一个元素赋值 for(int j = 0;j<9;j++) for(int k = 0; k&lt...

2018-09-19 20:13:23 1610 1

原创 c++动态创建对象一维数组

#include<iostream>using namespace std;class Point{public:Point(int x,int y):x(x),y(y){ cout << "调用构造函数"<< endl; } Point():x(0),y(0){ cout << "调用默认构造函数"<< en

2018-09-19 18:45:26 2725 2

原创 c++ 简单的动态分配内存空间

#include<iostream>using namespace std;class Point{public: Point():x(0),y(0){ cout<<"调用默认构造函数"<<endl; } Point(int x,int y):x(x),y(y){ cout<<"调用构造函数"<<endl;

2018-09-18 21:24:58 420

原创 c++ 通过指针来访问类的成员

#include<iostream>using namespace std;class Point{public: Point(int x = 0,int y = 0):x(x),y(y){//构造函数初始化 } int getx(){return x;//访问成员x的接口 } int gety(){return y;//访问成员y的接口 } privat...

2018-09-18 20:21:22 2653

原创 c++函数指针的简单运用

#include<iostream>using namespace std;int computer(int a, int b, int(*func)(int , int)){//指向函数的指针 所指向的函数原型的返回值是int类型的 参数是两个int 类型的 return func(a,b);}int max(int a, int b){//求最大值 return...

2018-09-18 20:07:15 194

原创 c++指针函数的的简单使用

#include<iostream>using namespace std;int main (){int *newintvar();int *intprt = newintvar();*intprt = 5;//访问的是合法有效的地址 delete intprt; //释放 return 0;} int *newintvar(){int *p = new in...

2018-09-18 19:48:03 138

原创 c++常指针做形参

#include<iostream>using namespace std;const int n = 6; void print(const int *p, int m);//常指针做形参 int main (){int a[n];//定义一个数组a,元素个数为nfor(int i = 0; i < n; i ++){ cin >>a[i];//输...

2018-09-17 21:19:24 340

原创 c++用指针做参数 ,简单的分离一个浮点数的整数部分和小数部分

#include<iostream>using namespace std;//将实数x分成整数部分和小数部分,形参 intpart,floatpart是指针 void splitfloat(float x, int *intpart, float *floatpart){*intpart = static_cast<int>(x);//取整数部分 *floa...

2018-09-17 20:51:04 3250 2

原创 c++ 指针数组的简单运用

#include<iostream>using namespace std;int main (){int line1[] = {1,2,3};int line2[] = {4,5,6,7};int line3[] = {7,8,9};int* pline[3] = {line1,line2,line3};//定义指针类型数组并初始化cout <<"输出矩...

2018-09-17 18:56:50 1277

原创 c++ 指针的简单运用

#include<iostream>using namespace std;class Employee{char* name;char* address;char* city;char* code;public://构造函数以及初始化 Employee(char* n="",char* add ="",char* ct ="",char* cd ="") :na...

2018-09-16 21:11:06 235

原创 c++ 简单的矩形转置

#include<iostream>using namespace std;//行和列的对调 说到底是元素和元素之间的对调 void swap(int &a, int &b){ int temp = a;a = b;b = temp;}int main(){int a[3][3];cout << "输入矩阵的元素:"<&lt...

2018-09-16 20:25:27 1351

原创 c++ void 类型的指针运用

#include<iostream>using namespace std;int main (){void *pv;//声明void类型的指针int i = 5;pv = &i; // void 类型指针指向整形变量int *pint = static_cast<int*>(pv);//void指针转换为int 指针cout<< "*p...

2018-09-13 20:50:39 1181

原创 c++ 简单的指向常量的指针 和指针类型的常量

#include<iostream>using namespace std;//const指针不能通过指向常量的指针改变所指对象的值,但指针本身可以改变,可以指向另外的对象 //若声明指针常量,则指针本身的值不能被改变 int main(){int a;const int *p1 = &a;//p1是指向常量的指针 int *const p2 = &...

2018-09-13 20:47:44 230

原创 c++ 指针的定义 赋值 和简单的使用

#include<iostream>using namespace std;int main(){int i; //定义一个整数类型的变量i i = 10;//给i赋值 int *ptr = &i;//定义一个 int 类型的指针 取i的地址给ptr cout << "i = " << i <<endl;cout<&lt..

2018-09-13 19:52:22 2792

原创 c++ 对象数组简单的运用举例

#include<iostream>using namespace std;class Point{public: Point(); Point(int x,int y); ~Point(); void move(int newX,int newY); int getX() const{return x;} int getY() ...

2018-09-13 18:56:05 974 2

原创 c++以数组名为实参 作为函数的形参

#include<iostream>using namespace std;void rowSum(int a[][4],int nRow){ // 我们操作数组a,相当于直接操作了数组 table for(int i = 0; i < nRow;i++){ for( int j = 1;j < 4;j++)//累加这一行 各列的值 ...

2018-09-13 16:06:32 1905

原创 c++运用一维数组简单的统计用户答题的正确率

#include<iostream>using namespace std;int main (){const char key[] = {'a','c','b','a','d'};// 定义一个常数组为正确答案 const int NUM_QUES = 5;// 定义问题个数为5char c;int ques = 0,numCorrect = 0;//ques作为KE...

2018-09-13 14:01:03 835

原创 c++ 简单的运用数组求fibonacci数据

#include<iostream>#include<iomanip>using namespace std;int main(){int f[20] = {1,1};for ( int i = 2;i <20;i++) f[i] = f[i - 2] + f[i - 1];for(int i= 0;i < 20; i ++){ if...

2018-09-11 21:26:16 252

原创 c++ 数组的定义 已经简单的运用

#include<iostream>using namespace std;int main(){int a[10],b[10];//定义俩个数组 a,bfor ( int i = 0;i < 10; i ++ ){ a[i] = 2 * i - 1; b[10 - i - 1] = a[i];}for ( int i = 0;i < 10 ;i...

2018-09-11 21:02:51 2307

原创 c++常成员函数举例

#include<iostream>#include<iomanip>using namespace std;class A{public: A(int i); void print();private: const int a; static const int b; // 静态常数据成员 初始化后 值保持不变 };/...

2018-09-11 18:13:23 195

原创 c++ 常类型 常对象常成员函数的定义和实现

#include<iostream>#include<iomanip>using namespace std;class R{public: R(int r1, int r2):r1(r1),r2(r2){ } void print(); void print() const; //常成员函数 private: in...

2018-09-11 17:49:38 636

原创 c++使用友元函数求两点之间的距离

#include<iostream>#include<cmath>using namespace std;class Point{public: Point(int x = 0,int y = 0):x(x),y(y){ } int Getx(){return x; } int Gety(){return y; }...

2018-09-10 21:25:50 4496 1

原创 c++类的静态成员函数创建和使用

#include<iostream>using namespace std;class Point{public: Point(int x, int y):x(x),y(y){// 构造函数并初始化 count ++; } Point(Point &p){//复制构造函数 x = p.x; y...

2018-09-10 20:58:16 633

原创 c++类的静态成员举例

#include<iostream>using namespace std;class Point{public: Point(int x = 0, int y = 0):x(x),y(y){//构造函数 count ++;//在构造函数中对count累加,所有对象共同维护一个count } Point(Point &p){//复制...

2018-09-10 20:21:19 215

原创 c++变量的生存期与可见性

#include<iostream>using namespace std;int i = 1;//i为全局变量,具有静态生存期。void other(){static int a =2;//a,b为静态局部变量,具有全局寿命,局部可见。 static int b;//只第一次进入函数时被初始化。int c = 10;//c 为局部变量,具有动态生存期,每次进入函数时都...

2018-09-10 19:36:44 437

原创 C++学习类的组合方法,构造函数,析构函数,成员函数的执行过程

#include<iostream>#include<iomanip>#include<cmath>using namespace std;enum CPU_Rank{ P1=1,P2,P3,P4,P5,P6,P7 };enum Ram_Leixing{ DDR1=1,DDR2,DDR3,DDR4};// 声明枚举类型 CPU_Rank p1-7...

2018-09-10 17:26:43 492

原创 c++简单的创建一个RAM 类

#include<iostream>#include<iomanip>#include<cmath>using namespace std;enum Ram_Leixing{ DDR1=1,DDR2,DDR3,DDR4};class RAM{private: Ram_Leixing leixing; int Rongliang...

2018-09-10 09:53:40 867

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除