- 博客(70)
- 资源 (4)
- 收藏
- 关注
原创 一些小方法诸如:交换值,排序,查找等等
#include<iostream>#include<windows.h>//#include"c:\Users\Administrator\Desktop\dd\aaa.h"//------strlen 没有结束符,sizeof 有结束符int a = 1;int b = 2;int arr[] ={1,2,6,4,8,9,11,55,23};int mu...
2018-12-19 19:00:10
231
原创 A*寻路
#include <algorithm>#include <iostream>#include <vector>#include <math.h>int W;int H;int S;struct Position{ Position(int _x = 0,int _y = 0) { x = _x; y = _y; ...
2018-12-19 18:32:07
232
1
原创 C++文件操作FILE
#include "stdafx.h"#include <iostream>//文件操作(写入文件)void main1(){ //定义一个文件指针 FILE* fp; //打开文件 //errno_t fopen_s(FILE** file, // const char* filename, // const char* mode); ...
2018-12-19 18:26:35
1128
原创 STL
后面夹带一个MAP,#include <iostream>#include <vector>//STL: standard template library 标准模板库//vector顺序表,list链表,map用于搜索的树形结构// string字符串类//class A//{//public:// class B// {//// }...
2018-12-19 18:24:21
161
原创 A*寻路C++ 代码
#include "AStar.h"//准备一张 开标 和 闭表std::vector<CAStar::_NODE>CAStar::open;std::vector<CAStar::_NODE>CAStar::close;#define _ABS(v) ((v) < 0 ? -(v):(v))#define _H_V(c, e) (_ABS...
2018-12-19 18:14:15
505
原创 win32框架黄金矿工
#include "..\\Frame\\Frame.h"#include "vector2.h"#include"game_input.h"#include<math.h>#include<Windows.h>#include<vector>#include<time.h>bool _go = false ;//抓取状
2018-12-19 18:05:56
326
原创 win32窗口 五子棋
#include “…\Frame\Frame.h”#include “vector2.h”#include"game_input.h"#include<math.h>#include<Windows.h>#include#include<time.h>struct QIZI{Vector2 qi ;int color ;};struct...
2018-12-19 18:04:20
305
原创 win32 框架 射线输出
#include "..\\Frame\\Frame.h"#include "vector2.h"#include"game_input.h"#include<math.h>#include<Windows.h>#include<vector>#include<time.h>struct xian{ Vector2 a
2018-12-19 18:02:56
153
原创 顺序表存取小练习
#include <iostream>#include <conio.h>struct kk { int type; int value;};#define DATA kkclass SXB{public: int len; int size; DATA* p; SXB() { len=0; size=1; p=new DA...
2018-11-29 18:13:42
219
原创 打星星
#include <iostream>#include <time.h>#include <windows.h>#include "SXB.h"#define w 15#define h 30#define s 450SXB zd; //子弹SXB dr; //敌人int x = w/2;int y = h-1;char smap[9]...
2018-11-29 18:08:02
244
原创 控制台小游戏:贪吃蛇
直接上代码了#include<iostream>#include"ff.h"#include<time.h>#include<windows.h>void main(){ srand((unsigned int)time(NULL)); init(); while(1) { MoveCursor(0, 0); draw(); ...
2018-11-28 11:54:41
362
原创 扫雷
这是一个简单控制台的扫雷!#include <iostream>#include "ff.h"#include <Windows.h>#include <time.h>void main(){ int h = 50 ; Init(h); while(1) { MoveCursor(0, 0); draw(); ...
2018-11-28 11:47:28
126
原创 调试方法
//调试手段://1)如果编译不成功,看输出面板,找到第一个error的地方//warming不用管//1>c:\users\administrator\desktop\调试\1.cpp(7) : error C2143: 语法错误 : 缺少“;”(在“.”的前面)//2)如果是逻辑错误,则需要打断点,看内存,看变量的值//a:打断点 F9 // F10逐过程 // F...
2018-11-23 13:50:46
248
原创 C 画画内存图
//-------------------------1------int a = 1;void f(int b){ int c = 2; c++; static int d = 1; d++; a += b + c + d;} int e = 3;void main(){ int p[] = {a,e,a+e}; char* q = "abcdef"; char w[...
2018-11-22 18:03:26
1120
1
原创 小练习
1: int a = 2; int b = 100; ExchangeInt1(a,b); std::cout<<a;//100 std::cout<<b;//22: int a = 2; int b = 100; ExchangeInt1(&a,&b); std::cout<<a;//100 s...
2018-11-22 17:59:49
192
1
原创 对称
#include<iostream> //□■□□ □□■□ □□□□#include<windows.h> //■■□□ □□■■ □■□□#define w 12 //□■□□ □□■□ ■■□□#define h 10 //□□□□ □□□□ □■□□#include<conio.h>int ...
2018-11-22 17:55:25
150
原创 内存这么认识
1、 short a = 48;//[30][00] a = 0x23456;//[56][34]2、如果数组的首地址为001CFF10 int drr[5] = {1,2,3,4,5}; std::cout<<(&drr[3]);//非char地址 001CFF1C std::cout<<*(&drr[5]-3);//变量 3 s...
2018-11-22 17:35:56
132
原创 C/C++醒脑总结
0 extern int a;//全局变量的声明1 int a;//一个整数类型的变量2 int* a;//一个int类型的指针3 int a[3];//一个int类型的数组,数组长度为34 int* a[3];//一个int类型的指针数组,数组长度为35 int a[2][3];//一个int类型二维数组6 int* a[2][3];//二维数组 指针数组7 int a();//函...
2018-11-22 17:34:01
130
原创 字符串->交换
数组作为形参时会自动退化成指针。个人觉得很形象#include<iostream>void ExchangeString(char* a,char*b)//(char a[],char b[]){ char tt[128]; char pp[128]; strcpy(tt,a); strcpy(pp,b); strcpy(a,pp); strcpy(b,tt);...
2018-11-22 17:29:42
326
原创 约瑟夫环问题-解法一
#include<iostream>void main(){ //A人游戏,从1~A编号 //从一号开始,报数(1,2,3;循环) //报到3号的出局,其余继续玩儿 //求最后剩余的人原来是:几号!! int in_a; std::cin>>in_a; const int A=in_a;//总共有多少人 int arr[A]={}; for(int ...
2018-11-18 11:57:17
197
转载 C++复习资料
?请填写bool、intfloat、、指针与“零值”进行相等判断的if语句--------------------------------------------------------bool a;int b;float c;void* d;//上述变量经过赋值之后与“零值”进行相等判断的if语句如下if (a){//具体执行语句}if (0 == b...
2018-11-16 09:38:18
641
原创 类:小测试-1
1: 打印结果?class A{ int a;public: A(int aa) { a = aa; std::cout<<"父构"<<a; } ~A() { std::cout<<"父析"<<a; }};class B : public A{ int b;public: B(int bb) : A(b...
2018-11-14 18:47:39
150
原创 类:小测试-2
1: class A{public: A() { std::cout<<"A构造"; } ~A() { std::cout<<"A析构"; }};class B : public A{public: B() { std::cout<<"B构造"; } ~B() { std::cout<<
2018-11-14 18:45:52
191
原创 模板:template
#include <iostream>int add(int a,int b){ return a + b;}float add(float a,float b){ return a + b;}double add(double a,double b){ return a + b;}//template是模板的意思,表示后面的函数是模板函数//type...
2018-11-12 11:55:57
134
原创 斗地主发牌系统
// ConsoleApplication2.cpp: 定义控制台应用程序的入口点。//#include "stdafx.h"#include <iostream>#include <time.h>#include <windows.h>#define DA 0#define XIAO 1#define HEI 2#define H...
2018-11-09 11:46:45
901
原创 类:两个练习题
class A{public: unsigned short a; unsigned short b; void f() { std::cout<< std::hex<<//十六 a<<","<< b;}};class B{public: unsigned int b; B(int bb):b(bb)...
2018-11-08 22:37:02
234
原创 类:继承-父类有带参构造
#include <iostream>class A{ int a;public: A(int a) { std::cout<<"父类构造\n"; } ~A() { std::cout<<"父类析构\n"; }};class B : public A{public: //当父类只有带参构造的时候,子类必须写构造函数,并...
2018-11-08 22:32:58
647
原创 类:继承-构造和析构的顺序
#include <iostream>//在继承体系下://创建对象时:先调父类构造,再调子类构造//销毁对象时:先调子类析构,再调父类析构class A{ int* p;public: A() { p = new int[10]; std::cout<<"父类构造\n"; } ~A() { delete [] p; std::...
2018-11-08 22:29:17
395
原创 类:队列
#include <iostream>class Queue : private LinkList{public: void Enter(DATA data) { push_back(data); } void Quit() { erase(0); } DATA* GetHead() { return Get(0); } int Length(...
2018-11-08 22:27:32
211
原创 类:继承-5-继承方式
#include <iostream>//class A{public://访问权限 int a;protected://访问权限 int b;private://访问权限 int c;};//继承方式 public继承 protected继承 private继承//父类public成员 变为子类public 变为子类protecte...
2018-11-07 20:43:50
150
原创 类:继承-4-静态成员
#include <iostream>//class A{public: static int a;//静态成员变量只有唯一一份 int b;};int A::a = 0;class B : public A{public: int c; void f() { A::a = 1; }};void main(){ std::cout<...
2018-11-07 20:42:01
170
原创 类:继承-3-访问冲突
#include <iostream>//命名冲突:int a;//全局变量aclass O{ void t() { a = 0;//全局变量a }};class A{public: int a;//自己成员变量a void h() { this->a = 0;//访问自己成员变量a a = 0;//访问自己成员变量a ::a = ...
2018-11-07 20:39:40
170
原创 类:继承-2-访问权限
继承访问权限#include <iostream>class A{public: int a;protected: int b;private: int c;public: int& GetC() { return c; }};class B : public A{public: void f() { a = 1;//子类可...
2018-11-07 20:37:51
176
原创 类:继承-1
#include <iostream>//类的三大特点:封装,继承,多态class Player{public: int hp;};class Moster1{public: int id; int hp; int mp; int attack; void Attack(Player* player) { player->hp -= 10; ...
2018-11-07 20:35:05
108
原创 成员函数——“this指针”
#include <iostream>class A{ static int a; int b;public: //成员函数:有一个隐形的“this”指针 void f1()//A* this { this->b; f2(); } //静态成员函数// 静态成员函数没有“this”指针 //不能访问成员变量以及成员函数,只能访问静态的成员变量和静态...
2018-11-07 09:39:34
799
原创 单例模式
#include <iostream>//单例模式: 指一个类只能创建一个类对象,则这个类就是单例//第一种方式:class Frame{ static Frame* one; //构造函数要私有 Frame(){} //拷贝构造要私有 Frame(const Frame& that){} //.......public: static Frame*...
2018-11-07 09:04:15
104
原创 const类对象与成员函数
const类对象,则只能调用const成员函数#include <iostream>//const成员函数class A{ int a;public: A(int aa):a(aa){} //const成员函数:**表示该函数不会修改成员变量** void f1() const { std::cout<< a <<std::endl...
2018-11-07 08:54:44
200
原创 友元:函数和类
#include <iostream>class A{ int a; //友元函数:f函数是A的朋友,则在f函数中,可以访问A的私有的东西 friend void f(); //友元函数:main函数是A的朋友,则在main函数中,可以访问A的私有的东西 friend void main(); //友元类:B类是A的朋友,则在B类的所有函数中都可以访问A的私有的东...
2018-11-07 08:48:10
94
原创 只是一个没有AI的单机版象棋
//代码之繁杂,没有整理,而且没有整理价值//记录一下学习行径还是可以的,或许咱都一样也不一定#include"game.h"#include<windows.h>#include<iostream>#include<conio.h>char *qizi[]={"帅","士","象","马","车
2018-11-06 21:24:50
351
原创 刚开始写算周几
#include<iostream>void main(){ int a,b,c,i=0; do { std::cout<<"请输入年份(2008~):"; std::cin>>a; } while(a<2008); do { std::cout<<"请输入年份(1~12):"; std::cin>
2018-11-06 21:18:23
134
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人