ASCII和二进制文件的输入输出First:包含头文件#include ASCII输入:
首先要创建一个in-stream对象:ifstream fin("input.txt"); 逐词读取:fin>>num>>s;
读取过程中遇到空白符,>>操作符就会停止读取内容,知道遇到另一个>...
分类:
其他好文 时间:
2014-05-26 22:15:05
阅读次数:
593
最近看到这篇文章dotNetDR_的回复,让我想起一个真实发生的案例,下面就简单说说这个关于lock引用类型的一个不容易发现的隐藏缺陷。某类库中的代码,封装了很简单的一个通用类,用于线程安全地执行某一种类型的特定方法,几行代码搞定:
public class ConcurrentObjectE...
分类:
其他好文 时间:
2014-05-26 14:01:09
阅读次数:
221
Given a set of candidate numbers (C) and a
target number (T), find all unique combinations inCwhere the candidate numbers
sums toT.Thesamerepeated num...
分类:
其他好文 时间:
2014-05-26 13:54:25
阅读次数:
282
基本上一次过,要注意边界条件的问题:如果在recursion里有两个参数int begin, end,
递归写作recursion(num, mid+1, end), 因为+号的原因,递归中是会出现begin > end
的情况的,所以考虑初始条件的时候应该要考虑充分。 1 /** 2 * Def....
分类:
其他好文 时间:
2014-05-26 12:12:49
阅读次数:
257
原题:http://acm.timus.ru/problem.aspx?space=1&num=18261826. MinefieldTime
limit: 0.5 secondMemory limit: 64 MBTo fulfill an assignment, a
reconnaissance...
分类:
其他好文 时间:
2014-05-24 12:57:02
阅读次数:
282
http://acm.timus.ru/problem.aspx?space=1&num=18241824.
Ifrit BomberTime limit: 0.5 second Memory limit: 64 MBIn the six years that
passed since the fi...
分类:
其他好文 时间:
2014-05-24 11:46:13
阅读次数:
298
1 #include 2 using namespace std; 3 4 int main() {
5 bool isPalindromic (int num); 6 int res = 0; 7 8 for(int i = 100; i res)11 ...
分类:
其他好文 时间:
2014-05-24 09:26:42
阅读次数:
168
【6.5】 1 #include 2 3 using namespace std; 4
#define MAXN 100 5 #define N 4 6 #define M 4 7 int x,y,num; 8 int a[MAXN][MAXN]
= { 9 {0,2,3,4},10 ...
分类:
其他好文 时间:
2014-05-23 03:06:42
阅读次数:
275
刷了这么长时间POJ了 可算看到了一个中文题,不容易啊~~。
题目大意:自己看。
解题思路:
dp[x1][y1][x2][y2][num]代表从(x1,y1)到(x2,y2)分成num+1块最小的平方和是多少。
下面是代码:
#include
#include
#include
int sum[10][10],board[10][10];
d...
分类:
其他好文 时间:
2014-05-22 23:06:07
阅读次数:
300
这几个题很典型也是国外一些知名公司经常会问到的题
3Sum:
排序,避免重复,时间复杂度O(n^2)
class Solution {
public:
vector > threeSum(vector &num) {
int len=num.size();
sort(num.begin(),num.begin()+len);...
分类:
其他好文 时间:
2014-05-22 17:25:02
阅读次数:
259