
c
张大川
程序员,IT民工
展开
-
链表 C语言实现
#include <stdio.h>#include <stdlib.h>typedef int ElemType;struct node { ElemType data; /*数据域*/ struct node *next; /*指针域*/} node;typedef struct node *LinkList;//指向结构的指针typedef stru原创 2017-03-21 18:12:21 · 625 阅读 · 0 评论 -
C语言实现万年历
C语言实现的万年历计算#include <stdio.h>#include <stdlib.h>#include <string.h>int main(int a, char** date){ int year = 0, month = 0, day = 0, week; int d, i, dm, dy, m2; char WEEK[9]; if (a ==转载 2017-12-25 17:04:36 · 989 阅读 · 0 评论 -
数据结构单链表
数据结构单链表#include <stdio.h>#include <stdlib.h>#define MAXSIZE 20#define OK 1#define ERROR 0#define TRUE 1#define FALSE 0typedef int Status;typedef int ElemType;typedef struct Node{ ElemType原创 2017-10-13 17:34:58 · 433 阅读 · 0 评论 -
数据结构栈C语言实现
根据《大话数据结构》整理#include <stdio.h>#define MAXSIZE 20#define OK 1#define ERROR 0#define TRUE 1#define FALSE 0typedef int Status;typedef int SElemType;typedef struct{ SElemType data[MAXSIZE];// 数组实现原创 2017-10-13 16:15:23 · 510 阅读 · 0 评论 -
数据结构C语言
数据结构C语言#include <stdio.h>#define MAXSIZE 20#define OK 1#define ERROR 0#define TRUE 1#define FALSE 0typedef int Status;typedef int ElemType; /* ElemType类型根据实际情况而定,这里假设为int */typedef struct{ El原创 2017-10-09 22:10:29 · 357 阅读 · 0 评论 -
C语言逆转字符串数组
逆转字符串数组#include <stdio.h>#include <string.h>char* reverse(char *x){ int tem,len=strlen(x); int n=len/2; for(int i=0; i<=n; i++) { tem=x[i]; x[i]=x[len-1-i原创 2017-10-18 18:12:12 · 1505 阅读 · 0 评论 -
const 与指针
const是一个C语言的关键字,它限定一个变量不允许被改变。使用const在一定程度上可以提高程序的安全性和可靠性 指向常量的指针: const int *pa; int const *pa; 两者等价。因为指向常量的指针有时候会指向常量,所以它具有这个性质:“不能靠解引用改变它指向的对象的值”,以此保护它所指向的常量例如: char *strchr(const char原创 2017-10-18 17:48:04 · 279 阅读 · 0 评论 -
C语言字符串创建方法
需要与时俱进,更新C语言字符串的创建方法。#include <stdio.h>#define strz "abcd"int main(void){ //char *str ={'a','b','c','\0'};//错误的,不能编译通过。 char str1[] ={'a','b','c','\0'}; char str3[4]={'a','b','c','\0'};原创 2017-10-07 22:39:24 · 2858 阅读 · 0 评论 -
C语言的数组名的特殊情况
看到国内的教材这样写:但是存在一些特殊情况。第一种:数组作为&运算符的操作数#include <stdio.h>int main(void){ int a[] = {1,2,3};//创建一个数组 int *l;//一个指向整数的指针 int(*p) [3];//一个指向指向数组的指针 l=a;//数组名只能代表一个指向整数的指针//p=a; p=&a原创 2017-10-07 16:37:30 · 388 阅读 · 0 评论 -
C 语言的浮点型问题
C语言对浮点型的没有加后缀的字面量按照双精度浮点型处理(double),如果将这样一个字面量赋值给一个单精度浮点型变量,可能会出现精度损失。但是无论GCC还是LLVM,在默认情况下都不对这种情况发出告警。如果要想发出告警,GCC需要添加“-Wfloat-conversion”,LLVM需要添加“-Wconversion”。原创 2017-10-06 22:10:43 · 668 阅读 · 0 评论 -
C 语言描述顺序表
#include <stdio.h>#define MaxSize 10/*静态顺序表的各种操作*//** 向顺序表中插入元素 *//** 参数Sqlist:表首地址 *//** 参数*len: 表的长度 *//** 参数i: 插入元素的位置 *//** 参数x:待插入的元素值 */void insertElem(int Sqlist[],int原创 2017-03-21 16:10:46 · 578 阅读 · 0 评论 -
二叉树实现
#include <stdio.h>#include <stdlib.h>typedef struct BiTNode { char data; /*结点的数据域*/ struct BiTNode *lchild , *rchild; /*指向左孩子和右孩子*/} BiTNod原创 2017-03-22 14:51:10 · 468 阅读 · 0 评论 -
C 语言实现队列
GCC 5.4 测试#include <stdio.h>#include <stdlib.h>typedef char ElemType;/** 队列节点*/typedef struct QNode { ElemType data; struct QNode *next;} QNode , *QueuePtr;/** 链接队列*/ typedef struct {原创 2017-03-22 13:09:01 · 475 阅读 · 0 评论 -
C语言实现顺序查找
C语言实现顺序查找#include<stdio.h>int search(int a[], int y, int x); /*对自定义的函数search进行声明*/int main(void){ int i, x, n; /*变量定义*/ int a[10]; printf("请输入10个数字!\n"); for(i = 0; i < 10; i++)原创 2017-12-25 18:08:44 · 17714 阅读 · 1 评论