![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c++
pzzpztyy2009
不予置评
展开
-
异或链表原理及实现
异或链表,时间换空间思想的应用,一种双向链表的实现方式,在链表节点地址域中只有前后节点地址的异或值,计算下一个节点时,可以用上一节点的地址和当前节点的地址域中的值进行异或操作,即可获取下一节点的地址值。原创 2024-05-06 15:50:17 · 148 阅读 · 0 评论 -
随机投点法计算Π值
#include <iostream>#include<time.h>using namespace std;const unsigned long maxshort = 65536L;const unsigned long multiplier = 1194211693L;const unsigned long adder =12345L;class randomnum{private: unsigned long seed;public: .原创 2021-07-13 19:48:54 · 735 阅读 · 0 评论 -
C++位域结构体举例
一种空间换时间的策略,输出结果第一行可能与编译器有关。#include <iostream>using namespace std;enum Level { FRESHMAN, SOPHOMORE, JUNIOR, SENIOR };enum Grade { A, B, C, D };class Student {public: Student(unsigned n...原创 2019-01-31 20:38:04 · 127 阅读 · 0 评论 -
示例代码-----变量的生存期可见性作用域
#include<iostream.h>int i=1; // i 为全局变量,具有静态生存期。int main() { static int a;// 静态局部变量,有全局寿命,局部可见。 int b=-10; // b, c为局部变量,具有动态生存期。 int c=0; void other(void); cout<<"---MAIN---\...原创 2019-01-31 23:08:30 · 273 阅读 · 0 评论 -
C++ Primer plus第一章
原创 2019-01-30 00:54:44 · 94 阅读 · 0 评论 -
c++输出问题,不得其解
一、输出为空#include<iostream>using namespace std;class A{ private: int a; public: A(int ap=5){ a=ap; } inline int get_a() { return a; }};int ma...原创 2019-01-31 01:58:23 · 146 阅读 · 0 评论 -
c++构造函数与拷贝构造函数,组合类构造函数
1、如果没有显示声明构造函数时,系统给生成构造函数,此时随机赋值,并不是0。若后面定义对象时有参数会报错。#include<iostream>using namespace std;class A{ private: int a; public: inline int get_a() { return a; }};...原创 2019-01-31 02:12:20 · 326 阅读 · 0 评论 -
c++示例代码-静态数据成员
#include <iostream>using namespace std;class Point {public: Point(int xx=0, int yy=0) {X=xx; Y=yy; countP++; } Point(Point &p); int GetX(){return X;} int GetY(){return Y;} ...原创 2019-02-18 19:13:04 · 164 阅读 · 0 评论 -
c++示例代码-友元
一、友元函数#include <iostream.h>#include <math.h>class Point //Point类声明{ public: //外部接口 Point(int xx=0, int yy=0) {X=xx;Y=yy;} int GetX() {return X;} int GetY() {return Y;} friend flo...原创 2019-02-19 17:57:04 · 178 阅读 · 0 评论