代码
邻家小宝
C++软件开发
展开
-
关于vector遍历erase的方法记录
关于vector遍历erase的方法记录原创 2022-01-27 21:47:23 · 989 阅读 · 0 评论 -
递归算法面试题
一、斐波拉契递归详解int Fib(int n) { if (n < 2) return 1; return Fib(n - 1) + Fib(n - 2);}3 == Fib(3);/* 3 == Fib(3); ↓ Fib(3 - 1) + Fib(3 - 2) ↓ ↓ Fib(2)原创 2020-11-25 09:14:54 · 208 阅读 · 0 评论 -
一到笔试题就犯晕索性把详解写在博客里
第一题、宏解析问题#define MUL(a,b) a * bprintf("%d", MUL(1 + 2, 1 + 2));考察的是宏解析后的代码是什么样子的:MUL(a,b) 解析后为 a * ba 转换为 1 + 2 、b转换为 1 + 2a * b 转换为 1 + 2 * 1 + 2 = 1 + 2 + 2 = 5第二题、字节对齐问题 32位环境下定义结构体#pragma pack(1)struct stu1{ char a; ...原创 2020-06-15 16:59:01 · 245 阅读 · 0 评论 -
由浅入深讲解动态类函数指针
1、首先描述一下指针值的含义:假设内存值的序列是这样描述的 : 我们定义一个 0 ~ 50 的正整数序列。 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,1,...原创 2020-03-18 19:43:48 · 1367 阅读 · 0 评论 -
CRichEditCtrl的简单使用:
<br /> AfxInitRichEdit();<br />在初始化,CRichEditCtrl类产生的时候,调用这个函数其实是注册该窗口类.<br /> <br />以下是不完整简单使用:<br />void CCmdREdit::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags){<br /> long start = -1;<br /> long last = -1;<br /> GetSel(start,last);<br /> switch(nCh原创 2010-08-25 12:05:00 · 420 阅读 · 0 评论 -
字符串试题
原型:extern int strlen(char *s);用法:#include 功能:计算字符串s的(unsigned int型)长度说明:返回s的长度,不包括结束符NULL。int strlen(const char *str){ if(!str)return 0; const char *p = str; while(*p++); return p - str原创 2014-03-12 22:15:30 · 655 阅读 · 0 评论 -
关于运算符的面试题
1、运算符int x = 2;int y = (x++) / 3;Y 的结果为 0;论证为什么为0的解释为(翻译以上过程):int func(int x){ return x;}int func1(int x){ int y = x; x = x + 1; return y;}void main(){ int x = 2; int y = func(func...原创 2018-06-05 11:49:33 · 663 阅读 · 0 评论 -
给MouseMove发送lParam鼠标位置消息
/*利用联合体的方式*/union { long lpt[2]; }param; param.lpt[0] = 200; param.lpt[1] = 200; LPARAM lParam; lParam = (LPARAM)param.lpt; SendMessage(WM_MOUSEMOVE,NULL,lParam); /*利用位移的方式(宏) 更优原创 2009-07-16 14:48:00 · 507 阅读 · 0 评论 -
a星算法
// astar.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include #include #define MaxRow 20#define MaxCol 30int themap[MaxRow][MaxCol]={{1,1,1,1,1,1,1,1原创 2009-06-07 22:41:00 · 1646 阅读 · 3 评论 -
转载的 自己也学学 dx初步认识
这周开始学习DX9.0,安装了SDK后,参考书的讲解开始学习,OGL暂时放弃,原因无非是使用者少,没有大的厂商支持等原因吧,下面写下学习中的一些收获和理解,以结交这方面的朋友,并暴露出自己未发现的缺点,由于使用DXUT框架,先简单介绍一下使用方法,非常简单的,下载地址 http://www.onlinedown.net/soft/5288.htm对了,你需要使原创 2009-06-07 22:43:00 · 578 阅读 · 0 评论 -
动态数组&双向链表
#include /*有N支猴子,需要从中选中一个大王,选择的规则如下, 猴子们围成一圈(每个猴子从1到N编号), 从1到M依次报数,每当报到M的猴子出列,紧接着从一个猴子接着报,重新从1开始,直到剩下最下最后一个猴子, 即为大王. 编程实现选出大王,其中N,M由用户从键盘输入. */ class m_k { private: // typedef m原创 2009-06-07 22:42:00 · 464 阅读 · 0 评论 -
双向链表
#include "stdio.h"/*构件(双向、循环)链表*/struct MonkeyNo{int nNum;MonkeyNo* pNext;MonkeyNo* pPre;};MonkeyNo* pHeader = NULL;void AddList(int nD){MonkeyNo* pNew = new MonkeyNo原创 2009-06-07 22:43:00 · 281 阅读 · 0 评论 -
解读linux对string.h函数的实现
关键字: string 函数 实现 C代码 <a title="复制代码" onclick="function onclick(){function onclick(){dp.sh.Toolbar.CopyToClipboard(this);return false;}}" href="http://writeblog.csdn.net/#">/*原创 2009-06-08 17:59:00 · 699 阅读 · 0 评论 -
内接圆绘制多边形公式
//利用矩形左上角与右下角进行绘制 void CalcPoints(const RECT& rc);void CPolyCtl::CalcPoints(const RECT& rc){ const double pi = 3.14159265358979; //装载圆心的坐标 POINT ptCenter; //计算半径所表示的位置转载 2009-06-23 13:00:00 · 981 阅读 · 0 评论 -
线段导航
//求直线与直线的交点bool CCQGrapView::GetLineIntersect(CPoint ptL1,CPoint ptL2,CPoint ptOL1,CPoint ptOL2,CPoint& rPoint) { double a1=ptL2.y-ptL1.y; double b1=ptL1.x-ptL2.x; double c1=p原创 2009-06-27 17:01:00 · 411 阅读 · 0 评论 -
双缓存的一个例子
// Windows 头文件:#include // C 运行时头文件#include #include #include #include #include "stdafx.h"//////////////////////////////////////////////////////////////////////////////////原创 2009-07-16 23:41:00 · 554 阅读 · 0 评论