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);
}
......
这几天我安装了一个Linux系统,想在里面学一下C语言的编写,发现在里面运行有一个好奇怪的现象:如下面
#include<stdio.h>
void mian(){
printf("hello world!");
}
输出没有结果!搞的我看了半天,程序没有错误啊!怎么这样!后来我把程序改为
#include<stdio.h>
void mian(){
printf("hello ......
修改makefile,在LIBS里面加上-lmemcached,比如原来 gcc test.c,现在 gcc test.c -lmemcached。这个库就是libmemcached提供的。
然后添加#include<libmemcached/memcached.h>,这个文件也是libmemcached提供的。
主函数里面需要添加:
memcached_st *memc;
uint32_t&nbs ......
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<string.h>
#include<windows.h>
#include<malloc.h>
#include<math.h>
typedef struct worker
{
int num; //编号
char name[15]; //姓名
char zhicheng[15];& ......
C测试小程序
1、 字符串类
1.1 strstr
功能:查找和获取子串
void test_strstr()
{
char *str="Borland Inte ......