- 博客(12)
- 收藏
- 关注
原创 桶排序(简化)程序演示
#include<stdio.h> # define N 7 int main(void) { int a[11]={0},i,j,t; for(i=0;i<N;i++) { scanf(" %d",&t); a[t]++; } for(i=0;i<10;i++)//升序 { for(j=1;j<=a[i];j++) { printf("%d ",i); } } printf("\n"); for(i=10;i>=0;.
2022-02-08 00:32:10 377
原创 快速排序程序演示
#include<stdio.h> void QuickSort(int*,int,int); int Located(int*,int,int); int main(void) { int i; int a[6]={7,9,3,5,8,4}; QuickSort(a,0,5); for(i=0;i<6;i++) { printf("%d ",a[i]); } return 0; } void QuickSort(int* a,int low,int high) { .
2022-02-02 01:35:06 98
原创 二叉树程序演示
#include<stdio.h> #include<stdlib.h> struct BTNode{ char character; struct BTNode* pLchild; struct BTNode* pRchild; }; struct BTNode* CreatBTree(void); void PreTraverseTree(struct BTNode*);//先序遍历 void InTraverseTree(struct BTNode*);//中序遍历 .
2022-02-01 21:04:50 1161
原创 汉诺塔程序演示
#include<stdio.h> void hannuota(int,char,char,char); int main(void) { int i; char ch1='A',ch2='B',ch3='C'; printf("请输入盘子的个数\n"); scanf("%d",&i); hannuota(i,ch1,ch2,ch3); return 0; } void hannuota(int n,char A,char B,char C) { if(1==n) { .
2022-01-10 00:10:17 183
原创 动态栈程序演示
#include<stdio.h> #include<stdlib.h> #include<stdbool.h> struct Node{ int data; struct Node* next; }; struct Stack{ struct Node* pTop; struct Node* pBottom; }; void init(struct Stack*); void push(struct Stack*,int); bool pop(struct St
2022-01-09 13:47:38 318
原创 循环队列程序演示
#include<stdio.h> #include<stdlib.h> #include<stdbool.h> # define N 7 struct Queue{ int *pBase; int front; int rear; }; void init(struct Queue*); bool is_full(struct Queue*); bool is_empty(struct Queue*); bool en_queue(struct Queue*,i.
2022-01-08 22:11:46 328
原创 单向链表复习
#include<stdio.h> #include<stdlib.h> struct link{ int data; struct link* next; }; struct link* init(void); int length(struct link*); void creatByHead(struct link*); void creatByRear(struct link*); void sort(struct link*); void insert(st...
2022-01-07 11:59:09 633
原创 单链表的操作
1.链表的初始化 struct link{ int data; struct link*next; } struct link* head;//定义头指针变量 head=(struct link*)malloc(sizeof(struct link));//头指针指向分配的头节点内存空间 head->next=NULL;//头节点指针域为空 2.尾插法建立链表 struct link *r,*s; int data; r=head;//r指向头节点 while(1) {
2021-11-28 21:55:40 217
原创 洛谷p5716月份天数 C语言
#include<stdio.h> int main(void) { int year,month,flag; int a[12]={31,29,31,30,31,30,31,31,30,31,30,31};//闰年每月天数 int b[12]={31,28,31,30,31,30,31,31,30,31,30,31};//平年每月天数 scanf("%d%d",&year,&month);//输入年份月份 if(year%400==0||...
2021-11-20 22:10:03 428 2
原创 洛谷p5740最厉害的学生 C语言
#include<stdio.h> struct Student{ // 定义结构体struct Student char name[20]; int chinese; int math; int english; int sum; }; int main(void) { struct Student student[1000];//定义结构体数组 int i,j,n,t,k; k=0; s...
2021-11-20 21:54:01 2439 1
原创 洛谷p5736质数筛 c语言
#include<stdio.h> #include<math.h> int sushu(int a)//判断一个数是否为质数 { int i=2; if(a==1) return 0; if(a==3||a==2) return 1; for(i=2;i<=sqrt(a);i++) { if(a%i==0) { return 0; } ...
2021-11-20 21:37:45 1699
原创 洛谷p4956Davor C语言
#include<stdio.h> int main(void) { int x=1,k=1,m=100; int n; scanf("%d",&n); for(x=1;x<=m;x++) { if((7x+21kn/52)) { printf("%d\n%d",x,k); break; } if(xm&&7x+21k!=n/52) { m=m-1; x=1; if(m==1&&7x+21k!=n/52) { m=100; k++; } } } re
2021-11-20 21:17:41 770
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人