介绍给大家一个快速排序的方法:
void sort(int a[ ], int l, int r)
{
int i = l;
int j = r;
int mid = a[(i+j)/2];
do
{
while(a[i]
while(a[j] >mid ) j--;
if( i
{
swap( a[i], a[j] );
}...
分类:
编程语言 时间:
2014-06-20 13:15:03
阅读次数:
292
一直想要写的 二叉树 中序 先序 后序遍历算法
递归的太简单了,就不写了。关键是非递归版本。
先序:
我自己的版本:
void RootPreTraverse(Node* p)
{
Stack S;
while(S not empty)
{
p=S.top();
S.pop();
Show(p);
if(p->right!=null)
S...
分类:
其他好文 时间:
2014-06-20 10:55:49
阅读次数:
279
/**给定正整数k( 2 int joseph(int k){ 3 int
m,t,a=1,b,i,n; 4 while(1){ 5 for(b=1;bk)14 return m;15 }16 a+=2;...
分类:
其他好文 时间:
2014-06-10 00:17:35
阅读次数:
261
遍历List集合中的元素的方法有两种:
第一种:利用迭代器遍历
代码1:
// 迭代器
Iterator it=list.iterator();
while(it.hasNext())
{
System.out.println(it.next());
}或者代码2:
for(Iterator it=list.iterator();it.hasNext();)
{
System.o...
分类:
其他好文 时间:
2014-06-08 15:22:50
阅读次数:
189
1 //break是结束整个循环体,退出了整个while循环 2 3 int x = 0; 4
while (x++ < 10) 5 { 6 if (x == 3) 7...
分类:
其他好文 时间:
2014-06-07 16:53:19
阅读次数:
190
/* 输入员工工资1000-10000之间,并按从大到小输出*/
#include
using namespace std;
int main( )
{
double salarys[500];
int n=0;
double t;
while(cin>>salarys[n])
{
n++; //从cin流读取数据
...
分类:
其他好文 时间:
2014-06-07 15:36:38
阅读次数:
191
最近看c++primer第四版的标准容器vector,讲到对vector容器的插入删除元素会使得end()的迭代器失效的问题,所以不建议程序员对end()的存储。
vector vec;
vector::iterator first=vec.begin();
while(first!=vec.end())
{
first=vec.insert(first,12);
first...
分类:
编程语言 时间:
2014-06-07 13:04:13
阅读次数:
230
在vm下redhat5下安装oracle 11g后,登录sqlplus 报:
sqlplus: error while loading shared libraries: /home/oracle/app/oracle/product/11.2.0/dbhome_1/lib/libclntsh.so.11.1: cannot restore segment prot after reloc:...
分类:
数据库 时间:
2014-06-07 12:00:29
阅读次数:
303
1 #include 2 #include 3 using namespace std; 4 5
/*计算一个整数的二进制中1的个数*/ 6 int NumberOf1( int n) { 7 int count = 0; 8 9 while (n) {10
11 ...
分类:
其他好文 时间:
2014-06-07 10:33:11
阅读次数:
181
double solve(){ double M,RM; double L = 0.0; double
R = INF; while (L + eps < R) { M = (L + R) / 2; RM = (M + R) / 2; ...
分类:
其他好文 时间:
2014-06-07 08:35:50
阅读次数:
252