随笔分类 - 数据结构之基础篇
摘要:1 #include "head.h" 2 3 struct node 4 { 5 int data; 6 char ch; 7 }; 8 9 void *func(void *arg) 10 { 11 struct node *mynode2; 12 13 mynode2 = (struct node *)(arg); 14 mynode2->data = 1; 15 mynode2->ch = 'c'; 16 17 return mynode2; 18 } 19 20 int main() 21 { 22...
阅读全文
摘要:MSDN里讲的一头雾水,给的例子也看不出区别!又是一个文档跟实现不一致的地方,虽然我还没找到能看出区别的例子,暂 且还是按照这两个函数最初的实现来理解吧,网上随便搜了几篇文章,总结他们的不同在于: memcpy是把source 指向的对象中的n个字符拷贝到destin所指向的对象中,返回指向结果对象的指针。 memmove也是把source 指向的对象中的n个字符拷贝到destin所指向的对象中,但过程就好象是先把source所指向的 对象拷贝到临时数组中,然后在从临时数组拷贝到destin所指的对象中,返回指向结果对象的指针。 但要注意,除memmove之外的字符串操作函数在拷贝同一...
阅读全文
摘要:#include <iostream>#include <string.h>using namespace std;#define Maxsize 100void cover(char ch[], char substr[], int index){ int size = strlen(ch); int sub_size = strlen(substr); int result = 0, j = 0; if((index+sub_size)>=size) ch[index] = '\0'; else { for(int i=index+sub_si
阅读全文
摘要:#include <iostream>using namespace std;void fun8(int x){ if(x<8) { cout<<x; } else { fun8(x/8); cout<<x%8; }}int main(void){ char ch[10]; int result = 0; cin>>ch; for(int i=0;ch[i]!='\0';i++) { if(ch[i]>='0' && ch[i]<='9') result = res
阅读全文
摘要:#include <iostream>#include <string.h>using namespace std;/*void change(char ch){ if(ch>='1' && ch<'10') { }}int main(){ char str[] = "12AEE"; for(int i=0;i<strlen(str);i++) { char ch = str[i]; change(ch); } return 0;}void fun1(int n){ switch(n)
阅读全文
摘要:对于编写多线程的朋友来说,队列具有天生的互斥性。在队列里面,一个负责添加数据,一个负责处理数据。谁不妨碍谁,谁也离不开谁,所以,队列具有天生的互斥性。#define MAX_NUMBER 1000L#define STATUS int#define OK 0#define FALSE -1typedef struct _QUEUE_DATA{ int data[MAX_NUMBER]; int head; int tail;}QUEUE_DATA; 此时,一个线程压入数据,操作为push_dataSTATUS push_data(QUEUE_DATA* pQueue, int da...
阅读全文
摘要:面试的同学经常提起在面试时经常有被问到关于链表逆置的问题,今晚有时间也就写了一个,在下面程序中有创建链表和逆置两个功能,具体代码如下:#include <iostream>using namespace std;typedef char node_type;typedef struct node{ node_type data; struct node *next;}node_list, *_node_list;_node_list createList(char data[], int size){ _node_list head,my_node; head = new node
阅读全文

浙公网安备 33010602011771号