01 2016 档案
摘要:1 // Stack.cpp : 定义控制台应用程序的入口点。 2 // 3 4 #include "stdafx.h" 5 #include 6 using namespace std; 7 8 template 9 struct Stack 10 { 11 private: 12 Type *_stack; 13 int _top; 14 int _min; 15 ...
阅读全文
摘要:参考: http://blog.csdn.net/anialy/article/details/7645535
阅读全文
摘要:最大子序列和的问题,数据结构与算法一书分析中给出了四种算法,最优的算法的时间复杂度为O(N), 算法的正确性分析没有给出过程,分析过程如下: 此算法将整个数组序列分成了不同的子序列,子序列有如下规则 若子序列只有一个元素,那么此元素的值必定为负数 若元素个数n>1,那么第一个元素值sub_array
阅读全文
摘要:// ListReverse.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <malloc.h>#include <iostream>using namespace st
阅读全文
摘要:编写一个程序,开启3个线程,这3个线程的ID分别为A、B、C,每个线程将自己的ID在屏幕上打印10遍,要求输出结果必须按ABC的顺序显示;如:ABCABC….依次递推。 使用条件变量来实现:
阅读全文
摘要:子线程循环 10 次,接着主线程循环 100 次,接着又回到子线程循环 10 次,接着再回到主线程又循环 100 次,如此循环50次,试写出代码。 #include <pthread.h>#include <stdio.h>#include <unistd.h> static pthread_mut
阅读全文