- 博客(42)
- 资源 (2)
- 收藏
- 关注
原创 【数据结构---3】带头双向循环链表代码练习
#include<stdio.h>#include<stdlib.h>#include <assert.h>typedef int Datatype;typedef struct DlistNode { Datatype data; struct DlistNode* _next; struct DlistNode* _prev;}Node,*...
2019-04-30 01:14:58 228
原创 【数据结构---2】动态顺序表知识点整理
#include <stdio.h>#include <stdlib.h>// 动态的顺序表 typedef int DataType;typedef struct SeqList{ DataType* _array; int _capacity; // 顺序表的总大小 int _size; // 顺序表中有效元素的个数 }...
2019-04-30 01:14:31 186
原创 【数据结构---1】不带头的单向非循环链表知识整理
#include<stdio.h>#include<stdlib.h>#include <assert.h>typedef int SLTDatatype;typedef struct SListNode{ SLTDatatype _data; struct SListNode* _Next;}Node,*PNode;typedef s...
2019-04-30 01:12:58 271 2
原创 【数据结构 ---Snake】基于链表制作的超级简单贪吃蛇
#define LEFT 0xE04B#define RIGHT 0xE04D#define PAGE_NUM 2enum{ START = 0, EXIT,};char click = 1;int sorce = 0;char name[1024] = { 0 };typedef struct Snake{ int x; int y; struct Snake*...
2019-04-28 17:02:56 1150
原创 【数据结构---START】时间复杂度和空间复杂度知识整理
如何衡量一个算法的好坏?答:算法的好坏由算法效率决定.算法效率分析分为两种:第一种是时间效率,第二种是空间效率。时间效率被称为时间复杂度,而空间效率被称作空间复杂度. 时间复杂度主要衡量的是一个算法的运行速度,所以时间复杂度越大说明运算效率越差什么是时间复杂度?答:一个算法所花费的时间与其中语句的执行次数成正比,算法中的基本操作的执行次数,为算法的时间复杂度时间复杂度为什么不...
2019-04-21 10:50:33 485
原创 【C语言---34】文件操作函数知识点整理
ANSIC规定使用fopen函数来打开文件,fclose来关闭文件FILE * fopen ( const char * filename, const char * mode );int fclose ( FILE * stream打开方式如下:“r”(只读) 为了输入数据,打开一个已经存在的文本文件 出错“w”(只写) 为了输出数据,打开一个文本文件 ...
2019-04-21 09:34:48 222
原创 【C语言---33】汽水瓶喝汽水(简化写法)
#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<stdlib.h>//汽水1元一瓶,2个瓶盖换一瓶,20元喝几瓶?int main(){ int i;//i是瓶盖的数量 int sum = 0; for (i = 50; i > 1; i /= ...
2019-04-18 15:59:36 322
原创 【C语言---Chess】超级无敌简易的三子棋
#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<stdlib.h>#include<time.h>//使用时间戳时要加头文件//创建命令行版本的菜单int Menu(){ printf("=================\n"); printf("1.开始游戏\n"); pr...
2019-04-18 15:28:07 287
原创 【C语言---32】查找数组的不成对出现的两个数(简化写法)
#include<stdio.h>#include<stdlib.h>int main(){ int arr[10] = { 8, 12, 10, 11, 9, 11, 9, 2, 2, 8 }; int i, sum=0; //for (i = 0; i < 10; ++i) //查找单独不配对的数的写法&nb...
2019-04-18 15:18:24 501
原创 【C语言---31】左旋字符串中的k个字符(简化写法)
#include<stdio.h>#include<stdlib.h>#include<string.h>void Blodd(char str[], int n){ int size = strlen(str); char tmp[1024] = { 0 }; int i = 0; n %= size;&...
2019-04-18 14:47:11 224
原创 【C语言---30】动态内存分配函数的练习
#include<stdio.h>#include<stdlib.h>int main(){ char* p = (char*)malloc(100 * sizeof(char)); if (p == NULL) { exit(EXIT_FAILURE); } free(p);&nb...
2019-04-18 11:56:30 254
原创 【C语言---29】判断一个字符串是否为另外一个字符串左旋得到(方法二)
#include<stdio.h>#include<stdlib.h>#include<string.h>int isBlood(char str1[],char str2[]){ int size = strlen(str1) ; strncat(str1, str1,size); strstr(str1, str2...
2019-04-18 10:36:12 216
原创 【C语言---28】判断一个字符串是否为另外一个字符串旋转之后的字符串
#include<stdio.h>#include<stdlib.h>#include<string.h>void Blood(char str[],int size,int n){ char tmp = { 0 }; for (int i = 0; i < n; ++i) { tmp =...
2019-04-16 15:53:24 254
原创 【C语言---27】左旋字符串中的k个字符
#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<stdlib.h>#include<string.h>//实现一个函数,可以左旋字符串中的k个字符//ABCD左旋一个字符得到BCDA//ABCD左旋两个字符得到CDABvoid Blood(char str[],int s...
2019-04-16 14:54:10 170
原创 【C语言---26】自定义类型部分知识梳理
结构是一些值的集合,这些值称为成员变量。结构的每个成员可以是不同类型的变量。struct Stu{char name[20];//名字int age;//年龄char sex[5];//性别char id[20];//学号};//分号不能丢在声明结构的时候,可以不完全的声明struct{ int a; char b; float c;}x;struct{ int ...
2019-04-16 12:31:32 274
原创 【C语言---ConnectBook】简易实现动态内存通讯录
#include<string.h>#include<windows.h>//实现一个通讯录;//通讯录可以用来存储1000个人的信息,每个人的信息包括:// 姓名、性别、年龄、电话、住址//提供方法://1. 添加联系人信息//2. 删除指定联系人信息//3. 查找指定联系人信息//4. 修改指定联系人信息//5. 显示所有联系人信息//6. 清空所...
2019-04-15 19:25:18 351
原创 【C语言---25】模拟实现Strchr
#include<stdio.h>#include <stdlib.h>#include <assert.h>#include <string.h>char* Strchr(const char *str, char c){ if (str == NULL) { return NULL; } for (int i = 0; st...
2019-04-14 18:13:31 145
原创 【C语言---24】模拟实现Memmove
#include<stdio.h>#include <stdlib.h>#include <assert.h>#include <string.h>void * Memmove(void * dest, const void * src, size_t num)//size_t num 是字节{ assert(dest != N...
2019-04-14 17:42:00 247
原创 【C语言---23】模拟实现Memcpy
#include<stdio.h>#include <stdlib.h>#include <assert.h>#include <string.h>void * Memcpy(void * dest, const void * src, size_t num)//size_t num 是字节{ assert(dest != NU...
2019-04-14 16:50:34 98
原创 【C语言---22】模拟实现strcmp
#include<stdio.h>#include <stdlib.h>#include <assert.h>#include <string.h>int Strcmp(const char* str1, const char* str2){ assert(str1 != NULL); assert(str2 != NULL); in...
2019-04-14 16:08:41 154
原创 【C语言---21】模拟实现strstr
#include<stdio.h>#include <stdlib.h>#include <assert.h>char * Strstr(const char* str1, const char* str2){ assert( str1!=NULL); assert( str2!=NULL); if (*str2 ==...
2019-04-14 14:43:10 95
原创 【C语言---20】喝汽水,汽水瓶问题
#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include <stdlib.h>int num(int n){ if (n != 0)//等于0是喝不了汽水的 { if (n != 1)//给的钱大于1元的情况下 { ...
2019-04-14 13:13:32 323
原创 【C语言---19】模拟实现strcat
#include<stdio.h>#include <stdlib.h>#include<string.h>#include<assert.h>char * Strcat(char * dest, const char * src){ assert(dest != NULL); assert(src != NULL)...
2019-04-14 12:12:31 154
原创 【C语言---18】模拟实现strcpy
#include<stdio.h>#include <stdlib.h>#include<string.h>#include<assert.h>char * Strcpy(char * dest, const char * src){ assert(dest != NULL); assert(src != NULL)...
2019-04-14 11:42:07 101
原创 【C语言---17】找出一个数组中单独出现的两个数字
#include<stdio.h>#include <stdlib.h>void swap(int* x, int* y){ int tmp; tmp = *x; *x = *y; *y = tmp;}void sort(int arr[], int size){ for (int i = 0; i &...
2019-04-14 11:18:46 732
原创 【C语言---16】杨氏矩阵查找一个数字是否存在, 时间复杂度小于O(N)
#include<stdio.h>#include <stdlib.h>#define Hang 3#define Lie 3int find(int arr[Hang][Lie],int hang,int lie, int n){ if ((n<arr[0][0]) || (n>arr[hang - 1][lie - 1]))...
2019-04-13 23:35:54 279
原创 【C语言---15】调整数组使奇数全部都位于偶数前面
#include<stdio.h>#include <stdlib.h>void paixu(int arr[], int left , int right ){ for (int left= 0; left< right; ++left) { if (arr[left] % 2 == 0) { int tmp; tmp = arr[le...
2019-04-13 19:27:04 335
原创 【C语言---14】字符数组逆序相关操作
#include<stdio.h>#include <stdlib.h>#include<string.h>char * fanxiangpailie2(char * str){ int i = 0; int start=0; for (; str[i]; ++i)//遍历 { if...
2019-04-12 21:31:59 302
原创 【C语言---13】找出一组数据中只出现了一次的数字(使用位运算)
#include<stdio.h>int main(){ int a[5] = { 1, 1, 3 ,3, 2 }; int res = 0; for (int i = 0; i < 5; ++i) { res ^= a[i]; } printf("%d\n", res);&nb...
2019-04-12 20:08:17 206
原创 【C语言---12】编写函数: unsigned int reverse_bit(unsigned int value); 这个函数的返回值value的二进制位模式从左到右翻转后的值
#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include <stdlib.h>#include<math.h>unsigned int reverse(unsigned int x){ int i; int tmp, sum = 0; for (i ...
2019-04-12 19:36:09 132
原创 【C语言---11】5位运动员参加了跳水比赛,成绩预测
#include<stdio.h>#include <stdlib.h>int chachong(int * player,int n){ int i,res = 0; for (i = 0; i < n; ++i) { res |= 1 << player[i]; }&nbs...
2019-04-12 17:11:17 467
原创 【C语言---10】编程推测谁是凶手
#include<stdio.h>#include<string.h>int main() int murder; for (murder = 'a'; murder < 'e'; murder++) { if ((murder != 'a') + (murder == 'c') + (murder == 'd') ...
2019-04-12 16:25:37 963
原创 【C语言---9】使用二维数组打印杨辉三角
#include<stdio.h>#include<string.h>int main(){ int data[10][10] = { 0 }; printf("%d\n",data[0][0] = 1); int i, j = 0; for (i = 1; i < 10; ++i) { &...
2019-04-12 16:18:46 1213
原创 【C语言---8】一些练习题
1.将数组A中的内容和数组B中的内容进行交换(数组一样大)#include<stdio.h>#include<stdlib.h>#include<math.h>void swap(int arr1[], int arr2[],int n){ int tmp; for (int i = 0; i < n; ++i) { tmp = arr...
2019-04-06 07:39:58 125
原创 【C语言---7】编写一个函数 (递归实现) 实现:将参数字符串中的字符反向排列
#include<stdio.h>#include<stdlib.h>#include<string.h>void fanxiangpailie(char * string){ char tmp; int mowei = strlen(string)-1;//末尾元素下标是长度减一 //首先确定跳出条件,s...
2019-04-04 15:16:50 373
原创 【C语言---6】一些练习题
1.递归和非递归求strlen非递归:#include<stdio.h>#include<stdlib.h>int strlen(char* str){ int i = 0; for (; str[i]; ++i);//字符串遍历 return i;}int main(){ char str="abcdefghijk"; printf("%d\n...
2019-04-04 15:15:22 113
原创 【C语言---5】一些练习题
1.递归和非递归分别求第N个斐波那契数:循环写法:#include<stdio.h>#include<stdlib.h>int fib(int x){ if (x== 1 || x == 2) { return 1; } int last3 = 1;//倒数第三项 int last2 = 1;//倒数第二项 int a=0;//最后一项 for ...
2019-04-04 15:09:45 132
原创 【C语言---4】一些练习题
1.用函数打印N*N的乘法表#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<stdlib.h>void chengfabiao( int* num){ int result; for (int a = 1; a <= *num; a++) { for (int b = 1; b &l...
2019-04-04 09:32:54 148
原创 【C语言---3】一些练习题
1.猜数字游戏:#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<stdlib.h>int menu() { //创建菜单,人机交互界面 printf("============\n"); printf(" 1.开始游戏\n"); ...
2019-04-03 14:13:27 206
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人