链接:http://poj.org/problem?id=3259
Description
While exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is very peculiar because it is a one-way path t...
分类:
其他好文 时间:
2014-06-05 05:26:33
阅读次数:
240
本文主要讲述基本的控制语句,if ,for ,while.但是里面很有可能有一些基础东西你没有注意到的!
在文章中用if for,while来实现了经典的猜数字,以及输出完美数(什么?完美数不知道?!开玩笑吧!)。
浅显易懂的例子和程序,最适合新手不过了。...
分类:
编程语言 时间:
2014-06-04 23:47:58
阅读次数:
442
最近遇到一个问题.就是
我在io线程里不断的把一个函数调用放到队列里
然后ruby线程就不断的从这个队列里取出函数之争并执行.
典型的 消费者模式.
我以前以为是这样...
这是work线程
pthread_mutex_lock(&mutex2)
while(( invoke = get_invoke() ) != NULL){
do_invoke(invo...
分类:
其他好文 时间:
2014-06-04 22:35:56
阅读次数:
408
#include
#include
#include
#include
using namespace std;
int pow(int x, int n)
{
int result = 1;
while (n > 0)
{
if (n % 2==1)
result *= x;...
分类:
其他好文 时间:
2014-06-03 05:08:33
阅读次数:
399
STL的队列和栈简单使用
#include
#include
#include
#include
#include
#include
using namespace std;
int main()
{
queue Q;
stack S;
int i;
for(i=1;i
{Q.push(i);S.push(i);}
while(...
分类:
其他好文 时间:
2014-06-03 03:51:26
阅读次数:
238
1.判断一个数是都是回文数
#include
int main(void)
{
int a[100] = {0};
int n;
printf("input n:");
scanf("%d", &n);
int i, k, j;
k = 0;
j = 0;
while(n != 0)
{
a[k++] = n % 10;
n = n / 10;
j+...
分类:
编程语言 时间:
2014-06-03 03:26:18
阅读次数:
255
An iterative way of writing merge sort:
#include
using namespace std;
void merge(int A[], int l, int r, int e, int B[]) {
int i = l, j = r, k = l;
while (i<r && j A[j]) B[k++] =...
分类:
其他好文 时间:
2014-06-03 02:33:24
阅读次数:
215
An iterative way of writing quick sort:
#include
#include
#include
using namespace std;
void quickSort(int A[], int n) {
stack> stk;
stk.push(make_pair(0, n-1));
while (!stk.empty()) {
pair ...
分类:
其他好文 时间:
2014-06-03 00:16:43
阅读次数:
357
git提交代码时,出现这个错误“error: The requested URL returned error: 403 Forbidden while accessing https”
解决方法:
编辑.git目录下的config文件即可。
vim .git/config
#修改对于的配置
#原来的url = https://github.com/elitecodegr...
分类:
数据库 时间:
2014-06-03 00:03:44
阅读次数:
349
阻塞IO实现:
public class PlainEchoServer {
public void serve(int port) throws IOException {
final ServerSocket socket = new ServerSocket(port);
try {
while (true) {
final Socket clientSocket...
分类:
其他好文 时间:
2014-06-02 23:32:20
阅读次数:
357