C/C++ 之旅
没想到 没想到 万万没想到
对C++八窍只通了7窍的我,竟然要开始搞c++了的说,真是好不刺激。
不敢相信,不敢相信。
类型是什么玩意?类怎么写?字符串怎么处理?怎么释放内存?
偶不知,不知,真的不知。。。。
哎 完都完了。
唉 不管怎么说都要去学的。。。一点辙都没有
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
namespace Algorythms
{
int insert_sort(int Array[],int Length)
{
for( int i = 0 ; i < Length ; i ++ )
{
int p = i;
for( int j = i ; j < Length ; j ++ )
{
if(Array[j] < Array[p])
{
p = j;
}
}
if(p != i) //Swap
{
int tmp = Array[p];
Array[p] = Array[i];
Array[i] = tmp;
}
}
return 0;
}
int Merge(int Array[],int p,int q,int r)
{
int a = q - p + 1;
int b = r - q;
int *L = new int[a + 1];
int *R = new int[b + 1];
int i = 0;
int j = 0;
for(i = 0; i < a; i ++)
{
L[i] = Array[p+i];
}
for(i = 0; i < b; i ++)
{
R[i] = Array[q+i+1];
}
L[a] = 0x7FFFFFF;
R[b] = 0x7FFFFFF;
i = 0;
j = 0;
for(int k = p; k <= r ; k ++)
{
if(L[i] <= R[j])
{
Array[k] = L[i];
i ++;
}
else
{
Array[k] = R[j];
j ++;
}
}
return 0;
}
int Merge_Sort(int Array[],int p,int r)
{
if(p < r)
{
int q = (p + r) / 2;
Merge_Sort(Array,p,q);
Merge_Sort(Array,q+1,r);
Merge(Array,p,q,r);
}
return 0;
}
int Reserver(int Array[],int Length)
{
int * e = Array + Length -1;
int * f = Array;
while(f < e)
{
int tmp = *f;
*f = *e;
*e = tmp;
f ++;
e --;
}
return 0;
}
int Exchange(int *a,int *b)
{
int tmp = *a;
*a = *b;
*b = tmp;
return 0;
}
int Bubble_Sort(int Array[],int Length)
{
for(int i = 0; i < Length - 1; i ++)
{
for(int j = Length - 1; j >= i + 1; j --)
{
if(Array[j] < Array[j - 1])
{
Ex
相关文档:
1.求下面函数的返回值(微软)
int func(x)
{
int countx = 0;
while(x)
{
countx ++;
x = x&(x-1);
}
......
#include <stdio.h>
#include <stdlib.h>
#define MAXSIZE 100
main()
{
FILE *fp;
if ( (fp = fopen( "c:\\a.txt", "r" )) == NULL ) printf("ERROR!\n");
int tmp[MAXSIZE];
int i;
for ( i=0; i<MAXSIZE; i++ )
{
tmp[i] = 0; ......
这几天我安装了一个Linux系统,想在里面学一下C语言的编写,发现在里面运行有一个好奇怪的现象:如下面
#include<stdio.h>
void mian(){
printf("hello world!");
}
输出没有结果!搞的我看了半天,程序没有错误啊!怎么这样!后来我把程序改为
#include<stdio.h>
void mian(){
printf("hello ......
先前在测试mysql connect c++接口的时候运行其官方提供的例子
21.5.5.6. MySQL Connector/C++ Complete Example 2
The following code shows a complete example of how to use MySQL Connector/C++:
/* Copyright 2008 Sun Microsystems, Inc.
This program is free software; you can redistribute it and/or modify ......