
C++
JPDAYSUNDAY
这个作者很懒,什么都没留下…
展开
-
网易2017内推笔试程序题
有 n 个学生站成一排,每个学生有一个能力值,牛牛想从这 n 个学生中按照顺序选取 k 名学生,要求相邻两个学生的位置编号的差不超过 d,使得这 k 个学生的能力值的乘积最大,你能返回最大的乘积吗? 解析:刚开始看这道题的时候,打算先将学生按照能力值从大到小排序并记录排序后所对应原来的编号,然后从最大值开始去;但是这样会存在两个问题,一个是序列中存在负数的情况,另一个是必须要按照顺序选取k名学原创 2017-08-15 11:19:26 · 517 阅读 · 0 评论 -
C++实现汽车订票系统(C++课程设计)
#include#include#include#include#define Maxsize 100using namespace std;struct Route{ char number[20]; char startandreach[20]; char type[20]; char longroute[20]; char time[20]原创 2012-12-12 15:45:54 · 6033 阅读 · 3 评论 -
色子游戏(随机数)
//不用随机数/*#include#include#define TRUE 1#define ERROR 0using namespace std;int Game1() //第一次投掷骰子的方法规则{ int n1,n2; cout cin>>n1>>n2; int s1=n1+n2; if((s1==7)||(s1==11)) return原创 2012-10-12 20:35:52 · 992 阅读 · 0 评论 -
循环链表实现删除数据 小孩转圈淘汰游戏(循环链表实现)
因为我使用了分开写的文件,把类的声明放在了头文件中,下面是类的定义#include#include"Cycling_Link.h"using namespace std;#define TRUE 1#define ERROR 0int Link::Initlist(){ head=new Data; if(NULL==head)return ERROR; hea原创 2012-11-07 23:52:37 · 3281 阅读 · 0 评论 -
c++课程设计 对日期的基本运算 使用重载
#include#include#include#define error 0using namespace std;class Calendar{private: int month; int date; string Day[7];//char Day[7][10];//私有成员不能初始化,而且字符数组要想赋值,要么就一个一个的赋值 int原创 2012-12-06 22:48:05 · 1209 阅读 · 0 评论 -
c++课程设计 对日期及时间的基本运算(时间类和日期类) 使用重载
#include#include#define error 0using namespace std;class Time{private: int hour; int minute; //int second;public: Time(int h,int m) { hour=h; minute=m; //second=s;原创 2012-12-06 22:50:59 · 2837 阅读 · 0 评论 -
设置未来时间,并通过倒计时显示器的界面显示
#include#include#include#define error 0using namespace std;class Time{private: int hour; int minute; int second;public: Time(int h,int m) { hour=h; minute=m; secon原创 2012-12-06 22:53:11 · 1681 阅读 · 0 评论 -
c++自动获取当前时间,并分别用整形输出
#include #include using namespace std;int main(){ time_t now; struct tm *fmt; time(&now); fmt = localtime(&now); couttm_year+1900tm_mon+1tm_mday<<" "; couttm_hourtm_mintm_sec原创 2012-12-07 09:05:27 · 1859 阅读 · 0 评论 -
小孩转圈淘汰游戏(数组实现)Jose类,Ring类
#includeusing namespace std;#define TRUE 1#define ERROR 0class Array{private: int *array; int length;public: void Initlist(int n); void Destorylist(); void output(); int Li原创 2012-12-06 22:56:08 · 1053 阅读 · 0 评论 -
c++实现重载分数的四则运算
#includeusing namespace std;class Point{private: int c_point; int m_point; char code;public: Point() { code='/'; } Point(int n1,int n2) { c_point=n1; m_point=n2;原创 2012-12-12 15:27:48 · 2550 阅读 · 0 评论 -
栈的链式存储
#includeusing namespace std;struct Data{ Data *next; int data;};class Link_Stack{private: Data *base; Data *top; int top1;public: Link_Stack() { Data *temp=new Data; temp->data=NU原创 2012-12-10 17:03:57 · 876 阅读 · 2 评论 -
c++实现万年历,从公元1年1月1日开始,这一天是星期一
//从公元元年一月一日是星期一开始计算//用类实现求万年历的算法#include#include#includeusing namespace std;class Calendar{private: int month; int date; string Day[7];//char Day[7][10];//私有成员不能初始化,而且字符数组要想原创 2012-10-23 22:18:08 · 5689 阅读 · 1 评论 -
迷宫 C++实现
//文件的输入,有墙#include#include#include#includeusing namespace std;const int max1=100*100; //加入墙const int max2=102;bool value[max2][max2]; //记录是否被访问过int原创 2013-03-07 19:13:01 · 7756 阅读 · 0 评论 -
树结构的应用:表达式类型的实现
#include #include#define TRUE 1#define FALSE 0#define OK 1#define ERROR 0using namespace std;struct BiTNode //结点的数据{ bool tag; //true为数字,false为字符 int num; char c; BiTNode *lchild,*原创 2013-05-01 18:35:39 · 2152 阅读 · 1 评论 -
C++ COLOR和COLORREF之间的相互转换
由于在GDI+中使用的是画笔工具是Pen,不是CPen,颜色参数也是COLOR或画刷(必须在构造函数进行初始化,本身是一个带有参数的类)而不是COLORREF,必须发生转换1.COLOR------COLORREFColor c; m_bBrush.GetColor(c); COLORREF color=RGB(c.GetR(),c.GetG(),c.GetB());原创 2014-12-30 13:47:50 · 12265 阅读 · 0 评论 -
Sublime常用插件分类
1.C++编译环境原创 2014-12-26 14:53:52 · 608 阅读 · 0 评论 -
Virtual应用在析构函数和构造函数调用中
1.在析构函数前面加上关键字virtual进行说明,称该析构函数为虚析构函数。例如:class B{virtual ~B();…};该类中的析构函数就是一个虚析构函数。如果一个基类的析构函数被说明为虚析构函数,则它的派生类中的析构函数也是虚析构函数,不管它是否使用了关键字virtual进行说明。说明虚析构函数的目的在于在使用delete运算符删除一个对象时,能保析构原创 2014-12-26 14:44:57 · 978 阅读 · 0 评论 -
GetMessage&PeekMessage 和SendMessage&PostMessage
在Window 下Chromium 利用了MFC 消息循环机制,借此,对MFC中消息获取和投放的几个函数进行总结下:一、GetMessage&PeekMessageGetMessage 函数结构如下: BOOL GetMessage( LPMSG lpMsg, // 一个MSG的指针 HWND hWnd,转载 2015-01-06 16:47:54 · 662 阅读 · 0 评论 -
WinSocket简单编程实验
转载:http://www.cnblogs.com/tornadomeet/archive/2012/04/11/2442140.html 这一节是计算机网络作业,windows socket编程,老师电脑上开一个服务器程序,公开ip地址和端口号,我们同学自己编写一个客户端,能与老师的服务器建立联系,两者能收发即可。这样的代码网上很多,而是就采用了孙鑫VC++第14讲的代码,下面是添加的一转载 2013-07-04 09:56:14 · 1815 阅读 · 0 评论 -
DLL文件 获取或修改
DLL文件即动态链接库文件,是一种可执行文件,它允许程序共享执行特殊任务所必需的代码和其他资源。Windows提供的DLL文件中包含了允许基于Windows的程序在Windows环境下操作的许多函数和资源。 DLL多数情况下是带有DLL扩展名的文件,但也可能是EXE或其他扩展名。它们向运行于Windows操作系统下的程序提供代码、数据或函数。程序可根据DLL文件中的指令打开、启用、查询、禁转载 2013-06-28 00:17:47 · 1357 阅读 · 0 评论 -
CFile::modeNoTruncate
CFile::modeNoTruncate 参数详细说明 MSDN上说到:CFile::modeNoTruncate Combine this value with modeCreate. If the file being created already exists, it is not truncated to 0 length. Thus the file转载 2013-07-18 15:38:16 · 4789 阅读 · 1 评论 -
C++ 判断主机是否处于联网状态下
直接让本机访问一个网站,如果成功的话,就说明成功联网,没有访问成功,则说明没有联网!!!#include#include #pragma comment(lib,"ws2_32.lib")#define LEN 1024 //接收数据的大小using namespace std;int main(){ //加载套接字库 WORD wVersionReques原创 2013-07-15 10:29:25 · 9936 阅读 · 4 评论 -
VC++实现小托盘的处理
// 实验一Dlg.cpp : implementation file//#include "stdafx.h"#include "实验一.h"#include "实验一Dlg.h"//添加的头文件#include "shlwapi.h"#define WM_NOTIFYICON WM_USER+1//#ifdef _DEBUG#define n原创 2013-07-11 20:17:20 · 2006 阅读 · 0 评论 -
图结构的应用:教学计划编制问题
有两种方法:一种没有学分排序,另一种考虑了学分排序,较推荐栈中排好序的方法,贪心更完全测试数据文本:C1 程序设计基础 # 2C2 离散数学 C1 3C3 数据结构 C1,C2 4C4 汇编语言 C1 3C5 语言的设计和分析 C3,C4 2C6 计算机原理 C11 3C7 编译原理 C3,C5 4C8 操作系统 C3,C6 4C9 高等数学 # 7 C10 线原创 2013-05-01 18:41:09 · 10730 阅读 · 5 评论 -
Sleep函数的使用
http://baike.baidu.com/view/2539437.htmSleep函数 函数名: sleep 功能:执行挂起一段时间 用法:unsigned sleep(unsigned milliseconds); 在VC中使用带上头文件 #include 在gcc编译器中,使用的头文件因gcc版本的不同而不转载 2012-12-06 09:39:36 · 1192 阅读 · 0 评论 -
迷宫找路径,只要找到了一条就跳出
#includeusing namespace std;int n;int Maze[101][101];bool vis[101][101];struct unit//栈中的单元,记录x,y坐标{ int x,y;};struct list{ int top;//栈顶指针 unit place[101*101]; list(){top=0;} bool ba原创 2012-11-19 19:40:46 · 938 阅读 · 0 评论 -
树的非递归实现的中序遍历
好纠结,还用了二级指针的传递,记开辟二级指针,刚开始以为好简单,后来写着写着好麻烦!!!还有什么比较好的,简单的请给点意见吧!//遍历二叉树的非递归实现#include#include#define STACKlength 100#define ADD 10 #define ERROR 0#define TRUE 1using namespace std;struct ECS_d原创 2012-11-06 23:07:34 · 814 阅读 · 0 评论 -
链表实现(线性,链表)
//顺序线性表 /*#includeusing namespace std;#define Virtuallength 100#define AddspaceList 50#define TRUE 1#define ERROR 0class List{private: int *item; int length; int MAXlength;pu原创 2012-10-12 20:38:15 · 660 阅读 · 0 评论 -
HDOJ1002
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1002简单的大数问题#include#includeusing namespace std;int main(){ char a[1001],b[1001]; int n,s1,s2,a1[1001],b1[1001],i,j,n1=0,t; cin>>原创 2012-07-27 23:58:16 · 564 阅读 · 0 评论 -
HDOJ2544
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2544最短路径问题:(迪杰斯特拉)算法,也可以用Floyed等算法,我自己用了Floyed,也可以用Dijkstra。1.Floyed#includeusing namespace std;int main(){ int N,M,A,B,C,d[101][101],i,j,原创 2012-07-28 14:15:32 · 941 阅读 · 0 评论 -
特殊矩阵的压缩矩阵及其转置
//已有数据稀疏矩阵的压缩存储及转置/*#include#includeusing namespace std;struct SYZ{ int i,j,v;};struct JZ{ int hang,lie; int n; SYZ *data;};void CSH(JZ &a){ a.hang=4; a.lie=5; a.n=原创 2012-10-12 20:40:13 · 1159 阅读 · 1 评论 -
循环队列及循环队列实现数值转换
#include#define Length 10#define ERROR 0#define TRUE 1using namespace std;class XU_DL{private: int *item; int front; int rear; int maxlength;public: XU_DL(int length=Length)原创 2012-10-12 20:41:26 · 914 阅读 · 0 评论 -
栈的实现
//顺序栈的实现/*#include#define STACKlength 100#define ADD 10 #define ERROR 0#define TRUE 1using namespace std;class SX_Stack{private: int *base; int top; int stacklength;public:原创 2012-10-12 20:42:44 · 572 阅读 · 0 评论 -
c++中关于逻辑预算的优先级问题
#includeusing namespace std;int main(){ int a=0,b=3; if(a!=0&&b++)cout else cout return 0;}解析:当一旦确定前面的值是不正确的,则后面就不要执行了!!!原创 2012-09-22 01:41:18 · 1152 阅读 · 0 评论 -
c++中有个清屏函数,system(“cls”)
#includeusing namespace std;void max(int &x,int &y){int a; cout int t; t=x; x=y; y=t; cin>>a; cout system("cls");}int main(){ int a,b; cin>>a>>b; cout system("cls")原创 2012-09-22 01:31:47 · 34659 阅读 · 2 评论 -
HDOJ2037
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2037方法:使用了贪心算法,只要求后面的一列数即可,就是对后面的一列数进行排序,然后一个一个的找出来,主要是要想到关键的是后面的一列数。#includeusing namespacestd;int main(){ int n,s,t1[100],t2[100],i,t,j;原创 2012-07-26 23:47:01 · 699 阅读 · 0 评论 -
HDOJ1228
题目:http://acm.hdu.edu.cn/status.php?user=jxufe_JP&pid=1228&status=5#include#include#include using namespace std;int change(char *p1){ if(strcmp(p1,"zero")==0) return 0; if(strcmp原创 2012-07-26 23:30:41 · 712 阅读 · 0 评论 -
建立动态的n维数组
建立一维的动态数组#includeusing namespace std;int main(){ int *p,n,i,n1; cin>>n; p=new int [n]; for(i=0;i<n;i++) { cin>>n1; *(p+i)=n1; } for(i=0;i<n;i++) cout<<*(p+i)<<" "; cout<原创 2012-10-15 21:35:41 · 2477 阅读 · 1 评论 -
c++实现快速排序(Bubble Sort)
递归实现#includeusing namespace std;int main(){void SX_Quick_Sort(int array[],int i,int j);int Quick_Sort(int array[],int i,int j);cout<<"Please input data number is:";int n,i,*p;cin>>n;p=new原创 2012-12-03 20:35:21 · 2232 阅读 · 0 评论 -
DFS算法,BFS算法遍历图
前提:所有图的实现我都只用了邻接矩阵进行图的存储DFS算法遍历图//图的遍历之深度优先搜索#include#define MAX 1000#define TRUE 1#define ERROR 0using namespace std;class Graph{private: int n; //结点个数的平方 int m; //节点的个数原创 2012-11-16 21:12:16 · 1526 阅读 · 0 评论