摘要: 第17章 经典数据结构类型 堆栈接口提供三种基本的操作:push、pop 和 top。 Push:把一个新值压入到堆栈的顶部。 Pop: 只把顶部元素从堆栈中移除,它并不返回这个值。 Top: 返回顶部元素的值,但它并不把顶部元素从堆栈中移除。 (1)堆栈接口 #ifndef STACK_H #de 阅读全文
posted @ 2016-04-27 11:34 绽放的四叶草 阅读(317) 评论(1) 推荐(0) 编辑
摘要: 第10章 使用结构和指针 typedef struct NODE { struct NODE *link; int value; } Node; 插入到一个有序单链表: #include<stdio.h> #include<stdlib.h> #include "sll_node.h" #defin 阅读全文
posted @ 2016-04-27 11:23 绽放的四叶草 阅读(342) 评论(0) 推荐(0) 编辑
摘要: 第9章 字符串 int ch; char strings[80]; FILE *input; (1)scanf(“%c”,&ch); printf(“%c \n”,ch); (输入字符串时自动添加’\0’) (2)ch = getchar(); putchar(ch); (3)gets( strin 阅读全文
posted @ 2016-04-27 11:16 绽放的四叶草 阅读(318) 评论(0) 推荐(0) 编辑
摘要: 第8章 数组 1.数组与指针 数组名是一个指针常量,也就是数组第1个元素的地址。 int a[10]; int b[10]; int *c; (1) c = & a[0]; &a[0]表示一个指向数组第1个元素的指针。 (2) c=a; 与 c = & a[0]; 等价 (3) b = a; 非法, 阅读全文
posted @ 2016-04-27 10:33 绽放的四叶草 阅读(267) 评论(0) 推荐(0) 编辑
摘要: 第6章 指针 1.在一组字符串中查找字符: #include<stdio.h> #include<assert.h> #include<stdlib.h> #define TRUE 1 #define FALSE 0 int find_char(char **strings , int value) 阅读全文
posted @ 2016-04-27 10:15 绽放的四叶草 阅读(230) 评论(0) 推荐(0) 编辑
摘要: 第1章 1.输入字符串 while((ch=getchar())!=EOF && ch!=’\n’) ; ch=getchar() while(ch!=EOF && ch!=’\n’) ch=getchar(); 这个样子冗余,可读性差 2.输入字符串,没有长度限制 int at_beginning 阅读全文
posted @ 2016-04-27 10:05 绽放的四叶草 阅读(204) 评论(0) 推荐(0) 编辑