自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(38)
  • 资源 (2)
  • 收藏
  • 关注

原创 C++ 继承抽象基类的接口及实现

class IA {    virtual int f1() = 0;};class IB : public IA {    virtual int f2() = 0;};template class CA : public Interface {    int f1() {        printf("CA::f1()\n");

2017-06-28 17:08:41 560

原创 同时求交集和差集

////// 传入的 inter,del,add 的 size 必须是 0.void GetIntersectionAndDifferences(const std::vector& lhs, const std::vector& rhs, std::vector& inter, std::vector& del, std::vector& add) { if (

2017-05-10 11:58:30 347

原创 多态(Polymorphism)

C++里多态的概念有点乱,有时间上Wikipedia上搜索了下相关词条,总结如下Polymorphism(computer science)在编程语言和类型理论中,Polymorphism(希腊语,意思为many shape)指的是单个接口对应多个类型实体。作为一个多态类型,它的操作(operation)也可以被提供给其他类型的value。存在几种完全不同类型的多态。1

2016-07-24 17:08:07 992

原创 笔试题(蘑菇街):回文串

[编程题] 回文串给定一个字符串,问是否能通过添加一个字母将其变为回文串。输入描述:一行一个由小写字母构成的字符串,字符串长度小于等于10。输出描述:输出答案(YES\NO).输入例子:coco输出例子:YES做减法,减去任意一个字符,如果是回文字符串,则返回true#include#includeu

2016-03-19 18:57:36 571

原创 笔试题(蘑菇街):最大间隔

最大间隔给定一个递增序列,a1 2 n 。定义这个序列的最大间隔为d=max{ai+1 - ai }(1≤i2 ,a3 ..an-1 中删除一个元素。问剩余序列的最大间隔最小是多少?输入描述:第一行,一个正整数n(1输出描述:输出答案。输入例子:51 2 3 7 8输出例子:4#include#include#i

2016-03-19 17:57:24 624

原创 搬圆桌

#include#includeusing namespace std;int fun(int r){ int x, y, x1, y1; cin>>x>>y>>x1>>y1; double tx = x - x1; double ty = y - y1; double distance = sqrt(tx*tx + ty*t

2016-03-19 17:29:00 427

原创 笔试题:发奖金

狐进行了一次黑客马拉松大赛,全公司一共分为了N个组,每组一个房间排成一排开始比赛,比赛结束后没有公布成绩,但是每个组能够看到自己相邻的两个组里比自己成绩低的组的成绩,比赛结束之后要发奖金,以1w为单位,每个组都至少会发1w的奖金,另外,如果一个组发现自己的奖金没有高于比自己成绩低的组发的奖金,就会不满意,作为比赛的组织方,根据成绩计算出至少需要发多少奖金才能让所有的组满意。 输入描

2016-03-15 15:20:13 1333

原创 搜狐笔试题:扎金花

两个搜狐的程序员加了一个月班,终于放假了,于是他们决定扎金花渡过愉快的假期 。游戏规则:共52张普通牌,牌面为2,3,4,5,6,7,8,9,10,J,Q,K,A之一,大小递增,各四张; 每人抓三张牌。两人比较手中三张牌大小,大的人获胜。 对于牌型的规则如下: 1.三张牌一样即为豹子 2.三张牌相连为顺子(A23不算顺子) 3.有且仅有两张牌一样为对子 豹子>顺子>对子>普通牌型

2016-03-15 14:47:27 1548

原创 笔试题:马戏团(搜狐)

搜狐员工小王最近利用假期在外地旅游,在某个小镇碰到一个马戏团表演,精彩的表演结束后发现团长正和大伙在帐篷前激烈讨论,小王打听了下了解到, 马戏团正打算出一个新节目“最高罗汉塔”,即马戏团员叠罗汉表演。考虑到安全因素,要求叠罗汉过程中,站在某个人肩上的人应该既比自己矮又比自己瘦,或相等。 团长想要本次节目中的罗汉塔叠的最高,由于人数众多,正在头疼如何安排人员的问题。小王觉得这个问题很简单,于是统

2016-03-14 17:50:33 1067

原创 C++读取指定文件内容

#include #include #include using namespace std;int main(int argc, char* argv[]){ if(argc != 2) { cout"<<endl; return -1; } char* filePath = argv[1]; ifstream fin; fin.open(filePath,

2015-12-04 12:16:00 898

原创 linux 下 gb18030 转码成 utf8

iconv -f gb18030  -t utf8 1.txt -o 2.txt

2015-11-18 15:57:53 1008

原创 获取两个已排序数组的第K大值

int getKth(int* nums1, int m, int* nums2, int n, int k) { if(m > n) return getKth(nums2, n, nums1, m, k); if(m == 0) return nums2[k-1]; if(k == 1)

2015-11-09 16:41:37 881

转载 求最长回文子串的Manacher算法,time O(n)

来源:http://www.cnblogs.com/biyeymyhjob/archive/2012/10/04/2711527.htmlhttp://www.felix021.com/blog/read.php?2040

2015-10-27 15:55:49 367

原创 二叉树的序列化和反序列化

/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */clas

2015-10-27 12:15:55 441

原创 LeetCode 51: N-Queens

class Solution {public: Solution() { for(int i=0; i<16; i++) arr[i] = 0; } vector> solveNQueens(int n) { vector> vecRes; vector board(n, strin

2015-10-26 16:01:34 359

原创 190 Reverse Bits

Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as0011100101

2015-05-06 23:51:17 387

原创 191 Number of 1 Bits

Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11' has binary representation 00000000

2015-05-06 23:46:39 321

原创 201 Bitwise AND of Numbers Range

Given a range [m, n] where 0 For example, given the range [5, 7], you should return 4.int rangeBitwiseAnd(int m, int n) { int i = 31; int tmp = 1; while(i>=0) {

2015-05-06 23:45:06 388

原创 202 Happy Number

Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares

2015-05-06 23:43:36 344

原创 203 Remove Linked List Elements

Remove all elements from a linked list of integers that have value val.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4 --> 5/** * Definition for singly-linke

2015-05-06 23:40:44 350

原创 205 Isomorphic Strings

Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character must be replaced with anot

2015-05-06 23:38:21 349

转载 Android 在SD和Internal memory之间移动App,具体做了什么?

Stack Overflow上有一个答案解释了系统在移动App时具体做的事。http://stackoverflow.com/questions/13043783/android-move-app-to-sdQ:Actually I want to find that what kind of items that are involved when we move the

2015-05-04 15:16:28 1535

原创 Android Drawable转byte[]

Drawable icon = app.loadIcon(pm);Bitmap bitmap = ((BitmapDrawable)icon).getBitmap();ByteArrayOutputStream stream = new ByteArrayOutputStream();bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stre

2015-04-27 22:20:47 2278

原创 数组循环左移

//有10个数,输入一个整数m就循环移动m个数void loopMove(int* pNum, int nSize, int nMove)//假设是左移{ nMove %= nSize; int* pTmp = (int*)malloc(nSize*sizeof(int)); for(int i=0; i<nSize; i++) { if( i>=nMove ) pTm

2015-04-09 17:36:10 812

原创 Windows平台下另一种将wchar_t*转换为char*的方法

std::wstring w( L"Some草泥马" );//wstring const size_t wSize = wcslen(w.c_str()) + 1; char* c = new char[wSize*2];//sz_char setlocale(LC_ALL, "chs");//设置语言 wcstombs(c, w.c_str(), wSize*2);//转换 delet

2015-04-02 15:15:32 426

原创 Windows平台下另一种将char*转换为wchar_t*的方法

#include const wchar_t *GetWC(const char *c){ const size_t cSize = strlen(c)+1; wchar_t* wc = new wchar_t[cSize]; mbstowcs (wc, c, cSize); return wc;}

2015-03-30 11:49:45 742

原创 获取目录的的所有文件,并给出列表

#include #include #include #include using namespace std;void print_table(int tableCount, int tableSize){ if(tableCount <= 0) return; char *p = (char*)malloc( (tableSize*(tableCo

2015-02-13 13:27:18 590

原创 宏 宽字符转多字节 多字节转宽字符

#define WTOC(wszSrc, szDest) \ WideCharToMultiByte( CP_ACP, 0, (wszSrc), wcslen(wszSrc), (szDest), \ (WideCharToMultiByte(CP_ACP, 0, (wszSrc), wcslen(wszSrc), NULL, 0, NULL, NULL)), \ NULL, NULL )

2015-01-22 11:09:19 681

原创 MFC下使用CFileFind获取文件夹下所有文件

void AddFileFromFolder(const CString strFolderPath){ CString strMatch = strFolderPath + _T("\\*.*"); CString strFullName; CFileFind finder; BOOL bWorking = finder.FindFile(strMatch); while (bWo

2015-01-12 17:28:53 8408

原创 LCS(最长子序列)

#include #define LEFTUP 110#define UP 111#define LEFT 112#define MAX_WIDTH 512#define MAX_HEIGHT 512char arr_c[MAX_WIDTH][MAX_WIDTH];char arr_b[MAX_WIDTH][MAX_WIDTH];void lcs(char* arr_x,

2014-10-09 20:13:59 597

原创 幸运三角形

/*时间限制:1000 ms | 内存限制:65535 KB难度:3描述话说有这么一个图形,只有两种符号组成(‘+’或者‘-’),图形的最上层有n个符号,往下个数依次减一,形成倒置的金字塔形状,除第一层外(第一层为所有可能情况),每层形状都由上层决定,相邻的符号相同,则下层的符号为‘+’,反之,为‘-’;如下图所示(n = 3 时的两种情况):+ - - + - + - +

2014-08-26 15:57:51 561

原创 选择文件夹

BROWSEINFO sInfo; ::ZeroMemory(&sInfo, sizeof(BROWSEINFO)); sInfo.pidlRoot = 0; sInfo.lpszTitle = _T("请选择一个文件夹:"); sInfo.ulFlags = BIF_DONTGOBELOWDOMAIN | BIF_RETURNONLYFSDIRS | BIF_NEWD

2014-08-15 09:58:25 579

原创 抽象数据类型(链表)

ADT.hADT.cmain.c

2014-07-25 14:55:02 2205

原创 深度优先搜索文件夹

深度优先搜索文件夹,带命令行。#include #include #include #include #include using namespace std;int clean_backslash2(char *str){ char *p; while(*str) { if(*str == '\\' && *(str+1) == '\\') { p

2014-07-24 15:38:49 659

原创 八皇后

int check_trialEx(int arr[][N], int n){ int sum, j, k; for (j=0; j<n; j++) { sum = 0; for(k=0; k<n; k++) sum += arr[k][j]; if(sum>1) return 1; } return 0;}void print(int arr[][N],

2014-07-22 18:13:15 622

原创 字节间反转和字节内反转

字节间反转void Reverse_BYTE(U8 *p,int bytelen){ int i; U8 temp; for(i = 0; i <(bytelen/2); i++) { temp = p[i]; p[i] = p[bytelen -1 - i]; p[bytelen -1 - i] = temp; }}

2014-07-15 15:35:15 942

原创 GF[2^n]下的多项式乘法

U8 multi_qs(U8 a, U8 b){U16 res1, tmp_a, tmp_b, tmp_turn, tmp_res, tmp_X;U8 i;tmp_a = a;tmp_b = b;tmp_X = 0xF5;tmp_turn = tmp_a;//i=0时if(tmp_b & 0x1)tmp_res = tmp_turn;elsetmp_re

2014-07-15 15:26:45 1404

原创 GF[2^n]下的多项式除法

#include typedef unsigned char U8;typedef char S8;typedef unsigned short U16;S8 getHigh(U16 num)//获取最高位的次数{int i = 15;for(; i>=0; i--){if( (U16)(num>>i) )return i;}return -1;}U16 div(U16 dividend, U16

2014-06-08 18:51:39 2685

GetPdfPageCount(获取PDF页码数)

1.类名是"PdfPageCount",位于名字控件"PdfPageCounter"下。作用是快速提取页面数目。 2.PdfPageCount类需要添加zlib依赖。 3.已经集成到MSVC工程,可以直接运行。提供命令行工具。工程中包含测试函数。

2015-01-30

smtp邮件发送器

用MFC写的一个邮件发送器,可以发送附件

2013-06-05

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除