![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C语言
培娜i
愿早日成为IT技术小神,加油加油~
展开
-
数据结构-基数排序
排序算法-基数排序原创 2022-08-07 21:16:34 · 91 阅读 · 1 评论 -
数据结构-桶排序
桶排序实现原创 2022-08-07 19:53:41 · 297 阅读 · 0 评论 -
数据结构--所有排序算法实现
数据结构--排序算法原创 2022-08-07 12:53:47 · 147 阅读 · 0 评论 -
数据结构-双向冒泡
头文件Sort.h#include<stdio.h>void doublebubble(int *L, int n);void swap(int *a, int *b);函数实现DoubleBubble.c#include"Sort.h"void swap(int *a,int *b) { int temp; temp = *a; *a = *b; *b = temp;}void doublebubble(int *L,int n) { int low .原创 2022-05-15 16:21:21 · 171 阅读 · 0 评论 -
数据结构-二叉树四种遍历实现
头文件Queue.h(为实现层次遍历)#include<stdio.h>#include<malloc.h>#include<assert.h>#include<stdbool.h>struct BinTreeNode;typedef BinTreeNode* EType;typedef struct QueueNode { BinTreeNode* data; struct QueueNode *next;}QueueNode;.原创 2022-05-09 20:47:44 · 361 阅读 · 0 评论 -
数据结构-链式队列实现
头文件Queue.h#include<stdio.h>#include<malloc.h>#include<assert.h>typedef int ElemType;typedef struct QueueNode { ElemType data; struct QueueNode *next;}QueueNode;typedef struct LinkQueue { QueueNode *front; QueueNode *tail;}L.原创 2022-05-09 20:06:02 · 383 阅读 · 0 评论 -
数据结构-栈的应用
头文件SeqStack.h#include<stdio.h>#include<malloc.h>#include<assert.h>#include<stdbool.h>#include<string.h>#define STACK_INIT_SIZE 8#define INC_SIZE 3typedef char ElemType;typedef struct SeqStack { ElemType *base; i.原创 2022-05-03 13:20:09 · 197 阅读 · 0 评论 -
数据结构-顺序队列实现
头文件SeqQueue.h#include<stdio.h>#include<malloc.h>#include<assert.h>#define MAXSIZE 10typedef int ElemType;typedef struct Queue { ElemType *base; int front; int rear;}Queue;void InitQueue(Queue*Q);void EnQueue(Queue *Q, ElemT.原创 2022-05-03 11:56:11 · 822 阅读 · 0 评论 -
数据结构-链栈实现
头文件(LinkStack.h)#include<stdio.h>#include<malloc.h>#include<assert.h>typedef int ElemType;typedef struct StackNode { ElemType data; struct StackNode *next;}StackNode,*LinkStack;void InitStack(LinkStack *s);void Push(LinkStac.原创 2022-05-03 11:25:42 · 115 阅读 · 0 评论 -
数据结构-顺序栈实现
头文件(SeqStack.h)#include<stdio.h>#include<malloc.h>#include<assert.h>#include<stdbool.h>#define STACK_INIT_SIZE 8#define INC_SIZE 3typedef int ElemType;typedef struct SeqStack { ElemType *base; int top; int capacity;}.原创 2022-05-03 00:33:09 · 384 阅读 · 0 评论 -
C语言-所有排序实现
头文件Insert.h#include<stdio.h>void Swap(int *a, int *b);void StraightInsert(int *a, int n);测试文件Main.c#include<stdio.h>#include"Insert.h" int main() { //1.直接插入排序(从小到大) int L[8] = { 49,38,65,97,76,13,27,49 }; int n = 8; Stra.原创 2022-04-27 18:37:30 · 967 阅读 · 0 评论 -
数据结构-双向链表实现
头文件DList.h#include<stdio.h>#include<malloc.h>#include<assert.h>typedef int ElemType;typedef struct Node { ElemType data; struct Node*next; struct Node*prio;}Node, *PNode;typedef struct List { PNode first; PNode last; int s.原创 2022-04-21 15:25:50 · 1295 阅读 · 0 评论 -
C语言-逆序链表
完整源代码:#include<stdio.h>#include <stdlib.h> typedef struct node { int id; struct node *next; }node; int main() { node* head = (node*)malloc(sizeof(node));//创建head结点 head->next = NULL; node *p = head;//工作指针p printf("请输入第一个结原创 2022-04-17 13:50:53 · 863 阅读 · 0 评论 -
C语言-该日期是本年第几天
完整源代码:#include<stdio.h>#include"4.17.h"#include <stdio.h>struct Date //定义一个结构体变量Date{ int year; int month; int day;}date;int days(int year, int month, int day) //days函数判断该日是本年的第几天{ int a[12] = { 31,28,31,30,31,30,31,31,30,31,30,3原创 2022-04-17 10:44:23 · 736 阅读 · 0 评论 -
C语言-冒泡排序
#include<stdio.h>int main() { int a[5]; int i = 0, j = 0, temp = 0; printf("请输入五个整数:\n"); for (i = 0; i < 5; i++) scanf_s("%d", &a[i]); for (i = 1; i <=4; i++) {//5个数需要比较4轮 for (j = 0; j <=4 -i; j++) //每次比较少一个元素 if (a[j] &g.原创 2022-04-14 21:17:30 · 212 阅读 · 0 评论 -
C语言-字符串拼接(不用strcat函数)
#include<stdio.h>int main() { char str1[100]; char str2[100]; int i = 0, j = 0; printf("请输入字符串1:\n"); gets(str1); printf("请输入字符串2:\n"); gets(str2); while (str1[i] != '\0') { i++;//找到str1的最后一个字符 } while (str2[j] != '\0') { str1[i++] = .原创 2022-04-14 19:51:02 · 8332 阅读 · 10 评论 -
C语言-字符串长度(不使用strlen函数)
#include<stdio.h>#include<string.h>int main() { char s[100]; int count = 0, i = 0; printf("请输入字符串:\n"); gets(s); for (i = 0; i < 100; i++) { if (s[i] == '\0') break; else count++; } printf("%s的长度为%d", s, count);}...原创 2022-04-14 19:07:25 · 4248 阅读 · 2 评论 -
C语言-逆序输出
#include<stdio.h>#include<math.h>int main() { int temp = 0, length = 0; int x[100]; printf("请输入数组长度:\n"); scanf_s("%d", &length); printf("请输入%d个整数:\n", length); for (int i = 0; i < length; i++) scanf_s("%d", &x[i]); for .原创 2022-04-14 18:19:16 · 4517 阅读 · 2 评论 -
C语言-插入排序
#include<stdio.h>#include<math.h>int main() { int i = 0, x[5], j = 0, temp; printf("请输入五个整数:\n"); for (i = 0; i < 5; i++) scanf_s("%d", &x[i]); for (i = 1; i < 5; i++) { for (j = i; j > 0; j--){ if (x[j ] < x[j-1]).原创 2022-04-14 17:44:38 · 205 阅读 · 0 评论 -
C语言-三角形-11
#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>int main(){ //思路 //1.输出结果看作矩阵 //2.两层循环:外层for控制输出行数,内层两个for,一个是空格,另一个是字母 int i, j, k; for (i = 0; i <= 25; i++)//控制行数 { for (j = 30; j >= i + 3; j--) printf(" "); for (k = 65; k &.原创 2022-04-14 15:11:52 · 176 阅读 · 0 评论 -
C语言--水仙花--10
#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>int main(){//水仙花 int bai, shi, ge, number; for (number = 100; number < 1000; number++) { bai = number / 100;//百位 shi = (number - bai * 100) / 10;//十位 ge = number % 10;//个位 if (numbe.原创 2022-04-13 17:05:15 · 80 阅读 · 0 评论 -
C语言-猜数字游戏
#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<math.h>#include<time.h>#include<stdlib.h>//#include<cstddef> //只是C++的头文件不能用在C中#include<stddef.h>void menu();//菜单函数void play();//开始游戏int main(){ int i.原创 2022-04-04 15:33:16 · 3447 阅读 · 0 评论 -
C语言-100至200之间的素数
#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<math.h>int main(){ //求100-200之间的素数 int i = 0, j = 0, count = 0; for (i = 101; i < 200; i += 2) { for (j = 2; j <= sqrt(i); j++) { if (i%j == 0) break; } if (.原创 2022-04-03 18:52:48 · 882 阅读 · 0 评论 -
C语言-最大公约数
#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>int main(){ //求最大公约数 int m=0, n=0, r = 0; printf("请输入两个数:\n"); scanf("%d%d", &m, &n); while (m%n) { r = m % n; m = n; n = r; } printf("最大公约数为%d", n);}...原创 2022-04-03 18:23:38 · 667 阅读 · 0 评论