自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(18)
  • 收藏
  • 关注

原创 实现选择排序

/* * 此程序用于实现选择排序 * 作者:zhy * 时间:2021/7/20 */#include <stdio.h>#include <stdlib.h>// 用双重循环实现// 参数array为排序数组首地址,参数len为排序元素个数void selectsort1(int *array,int len);// 使用递归实现// 参数array为排序数组首地址,参数len为排序元素个数void selectsort2(int *array,in

2021-07-30 09:26:48 130

原创 实现基数排序(数组+链表)

/* * 此程序用于实现基数排序 * 作者:zhy * 时间:2021/7/24 */#include <stdio.h>#include <stdlib.h>#include <string.h>// 用于存放数据的节点typedef struct inode{ int data; struct inode *next;}inode,*pnode;int getcount(int obj);int getnum(int obj,in

2021-07-30 09:23:45 166

原创 实现快速排序

/* * 此程序用于实现快速排序 * 作者:zhy * 时间:2021/7/21 */#include <stdio.h>#include <stdlib.h>// 递归实现主函数// 参数:left 左标 right 右标// 参数:arr 排序数组首地址void quicksort(int *arr,int left,int right);int main(int argc,char *argv[]){ int arr[]={44,3,38,5,4

2021-07-30 09:22:16 88

原创 归并排序(递归实现)

/* * 此程序用于实现归并排序(递归实现) * 作者:zhy * 时间:2021/7/21 */#include <stdio.h>#include <stdlib.h>#include <string.h>// 归并排序用递归实现void mergesort(int *arr,int len);// 递归调用子函数void _mergesort(int *arr,int *arrtmp,int start,int end);int ma

2021-07-30 09:21:32 107

原创 实现归并排序

/* * 此程序用于实现归并排序 * 作者:zhy * 时间:2021/7/21 */#include <stdio.h>#include <stdlib.h>#include <string.h>int min(int a,int b);// 归并排序用循环实现void mergesort1(int *arr,int len);// 归并排序用递归实现void mergesort2(int *arr,int len);int main

2021-07-30 09:20:34 78

原创 实现插入排序

/* * 此程序用于实现插入排序 * 作者:zhy * 时间:2021/7/21 */#include <stdio.h>#include <stdlib.h>// 插入排序实现// 参数 array 排序数组的首地址// 参数 len 参与排序元素的个数void insertsort(int *array,int len);int main(int argc,char *argv[]){ int arr[]={44,3,38,5,47,15,36

2021-07-30 09:19:25 54

原创 实现希尔排序

/* * 此程序用于实现希尔排序 * 作者:zhy * 时间:2021/7/21 */#include <stdio.h>#include <stdlib.h>// 对同一组的元素进行插入排序// 参数 arr 需要排序的数组首地址// 参数 span 本次排序各元素位置的跨度// 参数 len 需要排序的数组长度void GroupInsertSort(int *arr,int span,int len);// 希尔排序函数// 参数 arr 需要

2021-07-30 09:18:33 96

原创 实现堆排序

/* * 此程序用于实现堆排序 * 作者:zhy * 时间: 2021/7/22 */#include <stdio.h>#include <stdlib.h>// 元素交换函数void swap(int &a,int &b);// 堆排序主函数// arr : 堆化数列首地址 // len :未排序的元素个数void heapsort(int *arr,int len);// 堆化函数(循环实现)// arr : 堆化数列首地址

2021-07-30 09:16:03 63

原创 冒泡排序实现

/* 此程序用于实现冒泡排序 * 作者:zhy * 时间:2021/7/20 */#include <stdio.h>#include <stdlib.h>// 使用双重循环实现// array是待排序数组的首地址,len参数是需要排序的元素个数void bubblesort1(int *array,int len);// 使用递归实现(单层递归)// array是待排序数组的首地址,len参数是需要排序的元素个数void bubblesort2(int

2021-07-30 09:05:48 82

原创 封装信号灯操作并结合共享内存应用

文章目录前言一、信号灯操作类二、操作主函数前言本程序皆为进程间通信,若需测试可运行两个相同进程一、信号灯操作类// 此类封装了信号灯操作class CSEM{private: union semun { int val; struct semid_ds *buf; unsigned short *arry; }; int sem_id; // 信号灯描述符public: bool init(key_t key); // 如果信号灯已存在,获取信号灯;如果信

2021-07-29 17:47:11 103

原创 socket通信多线程的服务端与客户端

文章目录前言一、通信服务端二、通信客户端前言本试验是在已实现多进程服务端的基础上(详情可查看我发布的另一个文章),将数据的收发分给交给两个线程完成一、通信服务端/* * 此程序用于测试线程级的tcp服务端并发 * 作者:zhy * 日期:2021/4/11 */#include "_public.h"CTcpServer TcpServer;void EXIT(int sig){ printf("程序退出,信号值:%d\n",sig); close(TcpServer.

2021-07-29 17:20:27 208

原创 对socket通信的封装以及实现服务端的多进程服务

文章目录前言通信服务端服务端main主函数服务端操作类通信客户端客户端main函数客户端操作类前言本篇内容是对已实现的通信程序进行模块化封装以及将服务端改为多进程并发通信,将初始化sokcet和recv与send操作封装成类,套接字描述符与通信实现的具体细节对用户隐藏。通信服务端服务端main主函数/* * 此程序演示socket通信服务 * 作者:zhy 时间:2020 4 4 */#include <stdio.h>#include <sys/socket.h&

2021-07-29 16:47:34 129

原创 简单实现Linux网络通信

文章目录前言一、通信服务端二、通信客户端前言本篇内容只实现基础的建立连接与半双工通信功能一、通信服务端/* * 此程序测试socket点对点的连接服务端 * 作者:zhy 时间:2020 4 5 */#include <stdio.h>#include <sys/socket.h>#include <unistd.h>#include <sys/types.h>#include <string.h>#include

2021-07-29 15:42:53 327

原创 关于可变参数的试验

/* * 此程序实验可变参数函数 * 作者:zhy 时间:2020 3 29 */#include <stdio.h>#include <stdarg.h>#include <string.h>void Printf(const char*,...);void Sprintf(char* str,const char*,...);int main(){ char buf[50]; memset(buf,0,sizeof(buf)); P

2021-07-29 15:19:35 57

原创 时间操作(字符串与长整数的转换)

前言用到的时间操作函数原型: time_t mktime(struct tm *tm);mktime函数用于把struct tm表示的时间转换为time_t表示的时间。struct tm * localtime(const time_t *);localtime函数用于把time_t表示的时间转换为struct tm结构体表示的时间,函数返回struct tm结构体的地址。/* * 此程序演示时间操作 * 作者:zhy 时间:2020 1 31 */#include <.

2021-07-29 15:00:40 434

原创 实现目录相关操作

文章目录前言一、逐级创建目录二、获取目录下的文件二、获取目录及其所有子目录下的文件前言对目录的操作有很多,本文只实现最常用的创建目录和获取目录下的文件以及获取目录及其所有子目录下的文件一、逐级创建目录/* * 此程序用于测试MKDIR函数 * 作者:zhy 时间:2020 1 30 */#include <stdio.h>#include <dirent.h>#include <string.h>#include <stdlib.h&gt

2021-07-29 11:31:19 107

原创 对文件操作的实例应用

文章目录前言一、文件拷贝二、写入和读取数据文件前言通过学习文件相关操作,尝试实现文件拷贝和对格式化数据的存取一、文件拷贝/* * 此程序用以文件复制 * 作者:zhy 时间:2020 1 22 */#include <stdio.h>#include <string.h>#include <stdlib.h>int main(int argc,char *argv[]){ if(argc!=3) { printf("\n这是一个文

2021-07-29 10:49:33 101

原创 文件操作学习

日常练习文章目录日常练习前言一、使用C语言库函数打开关闭文件二、文本文件文件读取与写入三、二进制文件文件读取与写入四、文件其他操作前言此部分为C语言在Linux下编程的相关操作一、使用C语言库函数打开关闭文件FILE *fopen( const char * filename, const char * mode );int fclose(FILE *fp);二、文本文件文件读取与写入写入文本文件int fprintf(FILE *fp, const char *format,

2021-07-29 10:18:02 99

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除