06 2011 档案

【C++/C FAQ】如何使用scanf指定输入字符串的格式
摘要://input is like: 1234ffff,4,5int R,X,Y;scanf("%x,%d,%d",&R,&X,&Y); 阅读全文

posted @ 2011-06-25 00:46 speedmancs 阅读(489) 评论(0) 推荐(0)

【C++/C FAQ】如何输入和输出十六进制的整数
摘要:int x; scanf("%x",&x); printf("%08x",12); 阅读全文

posted @ 2011-06-25 00:30 speedmancs 阅读(784) 评论(0) 推荐(0)

【C++/C FAQ】如何格式化输出以0填充的定长整数
摘要:printf("%02d:%02d:%02dpm\n",12,0,0); 阅读全文

posted @ 2011-06-24 23:24 speedmancs 阅读(751) 评论(0) 推荐(0)

【C++FAQ】怎么输入一行字符串(可能带空格)
摘要:#include <iostream>#include <vector>#include <algorithm>#include <string>#include <map>#include <cmath>using namespace std;int main(){ string str; while (getline(cin,str)) { cout << str << endl; } return 0;} 阅读全文

posted @ 2011-06-24 18:27 speedmancs 阅读(486) 评论(0) 推荐(0)

【C++FAQ】怎么给结构体排序
摘要:使用stl中的sort,并重载要排序的结构体或类的<号即可。示例代码如下(pku1007题)#include <iostream>#include <vector>#include <algorithm>#include <string>#include <map>#include <cmath>using namespace std;//只有ACGT这几个数class DNAStr{public: bool operator < (const DNAStr& other) const{ if (inv 阅读全文

posted @ 2011-06-24 17:25 speedmancs 阅读(573) 评论(0) 推荐(0)

【C++FAQ】如何设定小数点后的显示位数
摘要:double avg = sum / 13;cout.setf(ios::fixed);cout.precision(4);cout << "$" << sum / 12 << endl; 阅读全文

posted @ 2011-06-24 15:37 speedmancs 阅读(703) 评论(0) 推荐(0)

c++ operator重载的例子
摘要:#include <iostream>using namespace std;class A{public: A(double _data = 0.0):data(_data){} A& operator = (const A& rhs) { data = rhs.data; return *this; } friend A operator + (const A& lhs,const A& rhs); friend A operator - (const A& lhs,const A& rhs); friend A operator 阅读全文

posted @ 2011-06-09 22:06 speedmancs 阅读(29689) 评论(0) 推荐(1)

【IT面试题007】英语字符串的分词程序
摘要:/*给你一个没有间隔的字符串“thisisasentence”,如何将他分割成如下的句子:“this is a sentence”。提供一个函数用来检验一个字符串是不是单词:bool dic(char* w);完成下列的函数。要求效率尽可能快。bool Detect(char* str){}尽量写出完整思路,最好有伪代码。提示: 递归,回溯。这里使用最长单词优先匹配 + 深度优先搜索+回溯的方法解决此问题。其中数据来源为一篇普通的英文文字,测试时大概有几千个英文单词,先进行预处理,得到长字符串和单词词典。在实现时,由于使用的是stl的string,接口和题目中给出的有所处理,但不影响解决该问题 阅读全文

posted @ 2011-06-05 21:49 speedmancs 阅读(1071) 评论(0) 推荐(0)

【IT面试题006】迷宫问题
摘要:/*迷宫问题1 表示可以走0 表示不可以走*/#include "stdafx.h"#include <iostream>#include <string>#include <vector>using namespace std;int pathX[1000];int pathY[1000];int curPathPointNum;int gPathCount = 0;int visited[10][10] = {0};int maze[10][10] = {0};int minPathLen = 1000000000;void Init 阅读全文

posted @ 2011-06-04 20:22 speedmancs 阅读(317) 评论(0) 推荐(0)

【IT面试题005】八皇后
摘要:/* 8皇后*/#include "stdafx.h"#include <iostream>#include <string>#include <vector>using namespace std;const int MAX_ELEMENT = 1000;int solution[MAX_ELEMENT];bool columnHasChess[MAX_ELEMENT];bool addDialogHasChess[MAX_ELEMENT]; bool subDialogHasChess[MAX_ELEMENT];int gN; //行 阅读全文

posted @ 2011-06-04 19:25 speedmancs 阅读(231) 评论(0) 推荐(0)

【IT面试题004】全排列
摘要:使用深度优先搜索/*套用深度优先搜索之全排列全排列 输入: n(<=26)输出:将 前n个小写字母全排列输出*/#include "stdafx.h"#include <iostream>#include <string>#include <vector>using namespace std;int gN;const int MAX_ELEMENT = 10000;char solution[MAX_ELEMENT];int selected[26];int gCurNum; int gSolCount;void PrintSol 阅读全文

posted @ 2011-06-04 18:26 speedmancs 阅读(265) 评论(0) 推荐(0)

【IT面试题002】将一个正整数拆成几个连续整数之和
摘要:/*将一个正整数拆成几个连续整数之和代码 sum = a + (a+1) + (a + n - 1) => 2 * sum = n * (2a + n - 1)*//*将一个正整数写成若干个整数之和,打印出所有的可能,每种和输出时,加数升序排列*/#include "stdafx.h"#include <iostream>#include <string>#include <vector>#include <cmath>using namespace std;int _tmain(int argc, _TCHAR* ar 阅读全文

posted @ 2011-06-04 18:07 speedmancs 阅读(688) 评论(0) 推荐(0)

【IT面试题003】将一个正整数写成若干个整数之和
摘要:将一个正整数写成若干个整数之和,打印出所有的可能,每种和输出时,加数升序排列#include <iostream>#include <string>#include <vector>using namespace std;vector<int> solution;int gNum; //目前的加数个数int gCurSum; //当前和int gN; //目标和int gSolCount;void PrintSolution(){ for (int i = 0;i < gNum;i++) { cout << solution[i 阅读全文

posted @ 2011-06-04 17:57 speedmancs 阅读(350) 评论(0) 推荐(0)

【c++题目003】关于析构
摘要:Which statement is false? a) Destructors are called when a pointer is deleted. b) Destructors are called when an object goes out of scope. c) Destructors are called when a reference goes out of scope. d) A virtual destructor should be used if the class has virtual methods. e) Base class destruc... 阅读全文

posted @ 2011-06-04 16:39 speedmancs 阅读(260) 评论(0) 推荐(0)

面试题收集
摘要:1.单词的反转,比如"I love this game" 反转后为"game this love i" 2.输入任意一个正整数n,输出比它大的最小质数 阅读全文

posted @ 2011-06-04 16:02 speedmancs 阅读(188) 评论(0) 推荐(0)

IT找工作的一些社区
摘要:1 积木网 http://bbs.gimoo.net/ 2.面试119 http://www.job006.com/bbs/index.php 阅读全文

posted @ 2011-06-04 16:00 speedmancs 阅读(164) 评论(0) 推荐(0)

【C++题目002】哪些不是STL的collection
摘要:Which of the following is not an STL collection?a) vectorb) listc) mapd) treee) set 当然是tree。前三个都很常用,map和set内部是红黑树。单独的tree在STL中没有。 阅读全文

posted @ 2011-06-04 15:54 speedmancs 阅读(211) 评论(0) 推荐(0)

【C++题目001】类的哪些部分不是由编译器自动生成的
摘要:Which of the following is not automatically generated by the compiler?a) default constructorb) copy constructorc)equality operator (op==)d) assignment operator (op=)e) destructor#include <iostream>#include <string>#include <assert.h>using namespace std;class A{};int _tmain(int argc 阅读全文

posted @ 2011-06-04 15:52 speedmancs 阅读(203) 评论(0) 推荐(0)

【面试题001】求出句子中没有出现过的所有字母
摘要:假如一个句子含有所有字母,就叫做pangrams. 比如: "A quick brown fox jumps over the lazy dog" 就是一个pangrams. 要求写一个C++函数, string getMissingLetters(const string& sA)这里sA 代表一个输入的句子。假如sA 不是pangrams, 那么函数应该输出所有sA缺失的字母。 输出的字母应该按字典顺序排列。 btw:字母不区分大小写,最后输出小写字母 #include <iostream>#include <string>using n 阅读全文

posted @ 2011-06-04 15:34 speedmancs 阅读(335) 评论(0) 推荐(0)

导航