C++
ferraborghini
这个作者很懒,什么都没留下…
展开
-
阿里笔试题,乱序序列的保序输出。
按自己的思想简单写了一下,多多交流。#include "stdafx.h"int insertInOrder(int *a,int num,int len){ int position; if (a[0]==0) { a[0] = num; position = 1; } for (int i = 0; i < len-1;i++) { if (num>a[i] && n原创 2015-04-02 23:34:59 · 845 阅读 · 2 评论 -
libevent windows vs2010
借鉴前人的经验,注意一点版本尽可能不要搞错,少走弯路。编译器:VS2010 libevent版本:2.0.22 下载地址:libevent-2.0.22 github比较容易下载。 OS:windows 10操作步骤: 1、下载后加压缩就不说了。 2、使用VS2010的命令行工具,会有环境变量的写入,默认使用nmake之类的进行编译。 3、修改以下三个文件,添加宏定义: 在以下3个文原创 2017-05-21 16:11:25 · 446 阅读 · 0 评论 -
thrift的编译过程
、 终于到终点了,之前的都是做前期准备一、thrift的编译。windows opnessl安装libevent windows vs2010Windows boost库安装 VS2010\thrift-0.9.3\lib\cpp下有VS工程文件thrift.sln,用VS2010打开之后,会看到两个工程。 1)libthrift工程配置: libthrift>属性->C/C++-原创 2017-05-21 20:27:35 · 1609 阅读 · 0 评论 -
C/C++编译链接过程详解
转载: http://blog.163.com/sentimental_man/blog/static/7300161820111016103418932/ 有些人写C/C++(以下假定为C++)程序,对unresolved external link或者duplicated external simbol的错误信息不知所措(因为这样的错误信息不能定位到某一行)。或者对语言的一些部分不知道为什么转载 2015-08-16 23:07:12 · 404 阅读 · 0 评论 -
模板类不支持分离编译
把定义和实现都放在头文件中吧。原创 2015-05-07 17:12:48 · 369 阅读 · 0 评论 -
C实现读取文件的每一行 并标号
FILE *readFile; fopen_s(&readFile, "file.txt", "r"); FILE *writeFile; fopen_s(&writeFile, "fileput.txt", "w"); char ch=0; int i = 1; ch = fgetc(readFile); if (ch != EOF&&ch原创 2015-04-30 01:25:25 · 540 阅读 · 0 评论 -
按规则插入结点,然后删除指定的结点。
输入: 5 //长度 2 //第一个节点 3 2 //3插入第二个节点 4 3 //。。。 5 2 //。。。 1 4 //。。。 3 //删除第三个节点 输出: 2 5 1 4 有些地方是为了凑答案,链表的头部插入和删除需要注意。void inse原创 2015-05-12 20:42:15 · 431 阅读 · 0 评论 -
华为OJ 字符串排序
写完之后,总觉得有点复杂。。 要求: 编写一个程序,将输入字符串中的字符按如下规则排序。 规则1:英文字母从A到Z排列,不区分大小写。 如,输入:Type输出:epTy 规则2:同一个英文字母的大小写同时存在时,按照输入顺序排列。 如,输入:BabA输出:aABb 规则3:非英文字母的其它字符保持原来的位置。 如,输入:By?e输出:Be?y 样例: 输入: A Famous原创 2015-05-12 14:24:14 · 1175 阅读 · 0 评论 -
输出链表倒数第K个节点
#include <iostream>#include <string>#include <vector>using namespace std;struct ListNode{ int m_nKey; ListNode* m_pNext;};void createLinkList(ListNode* &pListHead, vector<int> data)原创 2015-05-12 19:56:00 · 603 阅读 · 0 评论 -
int型数据逆置
int numReserve(int num){ int numReserve = 0; while (num != 0) { if (numReserve == 0) { numReserve = num % 10; } else { numRes原创 2015-05-11 18:16:14 · 439 阅读 · 0 评论 -
关于字符串和内存空间的一些知识
#include "stdafx.h"#include <iostream>#include <stdio.h>using namespace std;char *getSpace(){ //char *p = (char *)malloc(100); char *p = "hello";//字符串常量内存没有释放,程序结束后由系统释放。返回指针,常量区当然不能写,可以读,因原创 2015-05-09 00:48:46 · 915 阅读 · 0 评论 -
C++单例模式的创建
#include "stdafx.h"#include <iostream>using namespace std;class Singleton{private: Singleton(); ~Singleton(); //static Singleton *instance;//本来想这样创建,但是静态成员变量必须初始化 public: stati原创 2015-04-20 15:50:13 · 422 阅读 · 0 评论 -
输出二叉树中随机两个结点的最小公共父结点
思路:当遇到一个结点是返回1,当左右子树都返回1的时候,即最小公共父节点。//二叉树的数据结构typedef struct MyStruct{ char data; struct MyStruct *leftChild; struct MyStruct *rightChild;}Node, *Tree;//查找方法int findFirstFather(Tree r原创 2015-04-14 01:14:52 · 911 阅读 · 0 评论 -
网易游戏2016实习生招聘在线笔试 推箱子
这两天又回顾了一下这个题目,整理之后做个保存吧,中间还有点问题,有时间再来改正,自己顺着思路一点点写下来的,逻辑比较简单。//计算当前的位置int *findPosition(char **a, int sign, int M, int N){ int *position = new int[2]; for (int i = 0; i < N; i++) {原创 2015-04-13 23:43:10 · 871 阅读 · 0 评论 -
#1039 : 字符消除
字符消除,正好简单复习一下,c++中的容器。容器使用起来还是比较方便的,包括string类型,代码还是要经常写写,才知道自己那些地方有问题。include原创 2015-04-07 01:34:13 · 691 阅读 · 0 评论 -
多态不能发生在父类的构造方法中
#include "stdafx.h"#include <iostream>using namespace std;class Father{public: Father(){ dosomething(); } void getMove(){ dosomething(); } virtual void dosomethi原创 2015-04-22 09:05:17 · 547 阅读 · 0 评论 -
windows opnessl安装
继续安装,搭建thrift环境。操作系统:win10 编译器:VS2010 openssl版本:openssl-1.0.1e 国内还是GitHub快一些 perl:ActivePerl 百度的软件下载安装步骤: 如何在Windows下编译OpenSSL (VS2010使用VC10的cl编译器) 1、使用VS2010下的Visual Studio 2010 Command Prompt进入原创 2017-05-21 19:45:23 · 2057 阅读 · 0 评论