- 博客(5)
- 收藏
- 关注
原创 算法小白第五天
##3用链表来存储数据 #include <stdio.h> #include <stdlib.h> //这里创建一个结构体用来表示链表的结点类型 struct node { int data; struct node *next; }; int main() { struct node *head,*p,*q,*t; int i,n,a; scanf("%d",&n); head = NULL;//头指针初始为空 for(i=1;i<=n;i++)//循环读入n个数
2021-05-29 17:03:45
203
原创 回文数
回文数 #include<stdio.h> //#include<stdlib.h> int main() { int n; int i; int tmp; int sum = 0; printf(“输入一个数:\n”); scanf("%d", &n); for (i = n; i; i /= 10)//数位遍历 { tmp = i % 10; sum = sum * 10 + tmp; } printf("%d\n", sum); if (sum == n) { prin
2021-05-01 16:03:46
80
原创 队列
**算法小白学习第四天 #include <stdio.h> int main() { int head,tail; int a[102]={0,6,3,1,7,5,8,9,2,4}; int i; head=1; tail=10;//最后一个数的后一个位置 while(head<tail)//当数组不为空的时候 { printf("%d ",a[head]); head++; a[tail]=a[head]; tail++; head++; } getchar(); getchar(..
2021-04-29 10:55:20
104
原创 2021-04-28
算法小白学习第三天 #include<stdio.h> int main() { int n ,a[1001],t,i; printf(“请输入参与人数:\n”); for(i=1;i<=1000;i++)//初始化数组为0 { a[i]=0; } scanf("%d",&n); for(i=1;i<=n;i++)//将出现的图书编号与桶排序类似进行标记 { scanf("%d",&t); a[t]=1;//如t=5,则a[5]=1;像这样将书号进行标记进数组 }..
2021-04-28 15:21:31
83
原创 快速排序
算法小白的学习 第二天-快速排序 #include<stdio.h> int a[100],n; void quickshort(int left,int right) { int i,j,temp,t; if(left>right) { return ; } temp=a[left];//temp 中存的是基数 i=left; j=right; while(i!=j) { while(a[j]>=temp && i<j)//先从右边找小于temp的,即基数
2021-04-27 15:42:49
142
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅