自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(55)
  • 资源 (1)
  • 收藏
  • 关注

原创 Mockito实现原理探析 -- Mockito.when(...).thenReturn(...)的一个简化实现

Mockito是一套非常强大的测试框架,被广泛的应用于Java程序的unit test中,而在其中被使用频率最高的恐怕要数"Mockito.when(...).thenReturn(...)"了。那这个用起来非常便捷的"Mockito.when(...).thenReturn(...)",其背后的实现原理究竟为何呢?为此,笔者实现了一个简单的MyMockito,来帮助帮助大家理解"Mockito.when(...).thenReturn(...)"的核心实现原理。

2015-11-24 21:52:48 24660 3

原创 110801 Little Bishops

// Refer to http://blog.csdn.net/metaphysis/article/details/6553011 to see the design of following program.import java.util.*;public class Main { private static void ClearArray(long[][] data, int

2013-12-18 15:39:30 772

原创 110707 Marbles

import java.util.*;public class Main { private static long GetGCD(long a, long b) { if (a == b) return a; if (a < b) return GetGCD(b, a); while(true) { long temp = b; b =

2013-12-10 16:24:42 641

原创 110703 Euclid problem

import java.util.*;public class Main { private static void EuclidAlgorithm(int a, int b) { if (a < b) { EuclidAlgorithm(b, a); int temp = ResultX; ResultX = ResultY; ResultY = te

2013-12-05 17:56:49 683

原创 110706 Smith Numbers

import java.util.*;import static java.lang.Math.*;public class Main { private static List s_Primes; static { s_Primes = new LinkedList(); s_Primes.add(2L); long limit = (long)sqrt(200000

2013-12-05 14:43:25 607

原创 110705 Summation of Four Primes

import java.util.*;import static java.lang.Math.*;public class Main { private static Map s_PrimesInfo; static { s_PrimesInfo = new HashMap(); } private static boolean IsPrime(int x) { B

2013-12-04 14:40:43 526

原创 110704 Factovisors

import java.util.*;import static java.lang.Math.*;public class Main { private static boolean IsPrime(int x) { int mid = (int)(sqrt(x)); for (int i = 2; i <= mid; ++i) if ((x % i) == 0)

2013-12-04 13:13:33 581

原创 110702 Carmichael Numbers

import java.util.*;import static java.lang.Math.*;public class Main { private static boolean IsPrime(long number) { long mid = (long)(sqrt((double)number)); for (long i = 2; i <= mid; ++i)

2013-12-02 14:05:48 492

原创 110701 Light, more light

//import java.io.*;import java.util.*;import static java.lang.Math.*;class Main implements Runnable{ /* static String ReadLn(int maxLength){ // utility function to read from stdin,

2013-12-02 13:55:11 688

原创 110604 Expressions

#include #include #include #include #include #include using namespace std;static const int STEP = 4;static const int UNIT = pow(10, STEP);class Integer{public: Integer(char* buf, int le

2013-11-26 16:54:34 605

原创 110603 Counting

#include #include using namespace std;class Integer{public: Integer(char* buf, int len) { for (int i = 0; i < len; ++i) m_data.push_back(buf[i] - '0'); } Integer() {} void Print()

2013-11-25 12:36:19 628

原创 110903 The Tourist Guide

#include #include #include #include using namespace std;class TouristGuid{public: TouristGuid(int cities, int roads) { int city1, city2, capacity; m_cities.resize(cities); for (int i

2013-11-20 15:45:19 792

原创 110902 Playing with Wheels

#include #include #include #include using namespace std;static void GetDigitsFromNumber(int number, int& thousands, int& hundreds, int& tens, int& ones){ ones = number % 10; number /= 10; t

2013-11-20 15:43:37 830

原创 110901 Bicoloring

#include #include #include using namespace std;class Graph{public: Graph(int vertexCnt) { m_vertexCnt = vertexCnt; int edges; cin >> edges; m_relations = new bool*[m_vertexCnt];

2013-11-20 15:42:09 711

原创 110602 How Many Pieces of Land

// Max = 1 + C(n, 2) + C(n, 4)// Refer to http://en.wikipedia.org/wiki/Dividing_a_circle_into_areas or // http://www.arbelos.co.uk/Papers/Chords-regions.pdf #include #include #include using

2013-11-18 13:25:15 608

原创 110601 How many Fibs

#include #include #include using namespace std;class Integer{public: Integer(const char* buf, int len) { Init(buf, len); } Integer() {} void Init(const char* buf, int len) { for (

2013-11-15 16:40:29 588

原创 110508 Pairsumonious Numbers

#include #include #include #include using namespace std;static int FindNumber(const vector& src, int target, int start, int end){ if (end < start) return -1; int mid = (start + end) / 2;

2013-10-29 14:48:18 535

原创 110507 The Stern-Brocot Number System

#include using namespace std;class SternBrocotNo{public: SternBrocotNo(int x, int y) : m_x(x), m_y(y) {} SternBrocotNo(const SternBrocotNo& other) : m_x(other.m_x), m_y(other.m_y) {} bool o

2013-10-28 13:05:36 429

原创 110506 Polynomial coefficients

#include using namespace std;static int C(int n, int k){ if (k == 0) return 1; int a = 1, b = 1; for (int i = 1; i <= k; ++i) { b *= i; a *= n; --n; } return a / b;}static int

2013-10-28 11:33:17 562

原创 110505 A multiplication game

This solution gets "Wrong answer" result inhttp://www.programming-challenges.com/,but it gets "Accepted" result inhttp://uva.onlinejudge.org/.I don't know why so far.#include #include

2013-10-25 17:43:10 541

原创 110504 Ones

#include #include using namespace std;static int s_Multiplier[] = {0, 1, 0, 7, 0, 0, 0, 3, 0, 9};static void Multiply(int src, int multiplier, int& result, int& flag){ result = src * multipli

2013-10-24 13:30:15 523

原创 110503 The Archeologists' Dilemma

// Suppose the given number is X, then// X*(10^Y) Y*log10 + logX < N < Y*log10 + log(X+1)// Another limitation is: Y > int(lgX) + 1#include #include using namespace std;static int SmallestIn

2013-10-24 11:04:38 555

原创 110502 Reverse and Add

#include #include #include #include #include using namespace std;static bool IsReverse(const char* num, int len){ int mid = len / 2; for (int i = 0; i < mid; ++i) { if (num[i] != num[len

2013-10-18 13:59:45 694

原创 110501 Primary Arithmetic

#include #include using namespace std;#define BUF_SIZE 1024static bool Add(const char& ch1, const char& ch2, bool currentFlag){ int num1 = ch1 - '0'; int num2 = ch2 - '0'; int flag = curren

2013-10-18 12:29:08 715

原创 110408 Football (aka Soccer)

This solution gets "Wrong answer" result inhttp://www.programming-challenges.com/,but it gets "Accepted" result inhttp://uva.onlinejudge.org/.I don't know why so far.#include #include

2013-10-17 12:16:26 547

原创 110407 ShellSort

This solution gets "Wrong answer" result inhttp://www.programming-challenges.com/,but it gets "Accepted" result inhttp://uva.onlinejudge.org/.According to the explanation in http://www.program

2013-10-16 13:22:51 537

原创 110406 CDVII

#include #include #include #include #include #include #include #include #include #include using namespace std;const int HOURS_IN_DAY = 24;const int MINUTE_IN_HOUR = 60;const int PASS_

2013-10-15 16:49:04 514

原创 110405 Shoemaker's Problem

#include using namespace std;class ShoeMaker{public: void Init(int index, int days, int punishment) { m_index = index; m_days = days; m_punishment = punishment; } class Comparer { p

2013-10-15 12:06:47 483

原创 110404 Longest Nap

#include #include #include #include using namespace std;#define TIME_UNIT 60static const int START_TIME = 10 * TIME_UNIT;static const int END_TIME = 18 * TIME_UNIT;class Interval{public:

2013-10-14 17:02:31 566

原创 110403 Bridge

#include #include using namespace std;template static void Swap(T* data, int index1, int index2){ if (index1 == index2) return; T temp = *(data + index1); *(data + index1) = *(data + inde

2013-10-14 11:46:59 504

原创 110402 Stacks of Flapjacks

#include #include #include #include using namespace std;static void GetVecFromStr(vector& data, char* str){ int i = 0; int firstDigit = -1; while(true) { if ((str[i] >= '0') && (str[i] <

2013-10-12 15:34:59 403

原创 110401 Vito's Family

#include #include using namespace std;#define ABS(x) (((x) < 0) ? -(x) : (x))template static void Swap(T* data, int x, int y){ if (x == y) return; T temp = *(data + x); *(data + x) = *(

2013-10-11 13:41:15 526

原创 110308 Fmt

#include #include #include #include #include using namespace std;enum CharType_t{ SPACE, NEWLINE, NORMAL};struct StrInfo{ StrInfo(char* str, int len, CharType_t charType) : m_len(l

2013-10-10 17:01:00 348

原创 110307 Doublets

This solution gets "Wrong answer" result inwww.programming-challenges.com/,but it gets "Accepted" result inhttp://uva.onlinejudge.org/.According to the explanation in http://www.programm

2013-09-23 17:23:22 533

原创 110306 File Fragmentation

#include #include #include #include #include #include using namespace std;#define MAX_CHAR_IN_LINE (256 + 2)static char s_buf[MAX_CHAR_IN_LINE];class Fragments{private: typedef map*>::i

2013-09-13 14:36:07 390

原创 110305 Automated Judge Script

#include #include #include #include using namespace std;#define MAX_LINES 100#define MAX_CHARS_IN_LINE (100 + 2)enum ComparisonResult_t{ ACCEPTED = 0, PRESENTATION_ERROR, WRONG_ANSWER};

2013-09-12 15:16:24 381

原创 110304 Crypt Kicker II

#include #include #include #include #include using namespace std;class CryptRule{public: CryptRule() { Clear(); } bool AddRule(char encryptedLetter, char decryptedLetter) { if (m_r

2013-09-05 13:24:28 792

原创 110303 Common Permutation

#include #include #include #include using namespace std;#define MAX_CHAR_IN_LINE 1002static void FormatStr(char* line){ int len = strlen(line); if (line[len - 1] == '\n') { line[len - 1

2013-09-04 16:52:15 594

原创 110302 Where's Waldorf (Where s Waldorf)

#include #include using namespace std;#define MAX_CHAR_IN_LINE 50static bool EastFind(char input[MAX_CHAR_IN_LINE][MAX_CHAR_IN_LINE], int rows, int cols, char* word, int wordLen, int curRow, in

2013-09-04 14:12:34 652

原创 110301 WERTYU

#include #include #include #include using namespace std;static void InitMapByChars(map& charMap, const char* info){ int nLen = strlen(info); for (int i = 1; i < nLen; ++i) charMap.insert(p

2013-09-03 17:12:11 398

c++语言的设计和演化

Writer : Bjarne Language : Chinese Very good book if you want to know deeply about C++.

2009-07-22

空空如也

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

TA关注的人

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