会员
周边
众包
新闻
博问
闪存
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
empty_thought
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
5
6
7
8
9
10
下一页
2020年12月18日
指针初探
摘要: 指针是C语言的灵魂,走进指针,来一场灵魂之旅! 以下仅包括用指针求和、找最值 #include <stdio.h> /* 指针替代数组的写法,初学时*x就是值的时候,x就是数组名,可是要赋初始位置 */ int f_sum(int a[],int n) { int *p=a; int sum=0;
阅读全文
posted @ 2020-12-18 00:17 empty_thought
阅读(64)
评论(0)
推荐(0)
2020年12月16日
return找素数
摘要: 找出2-5000里面所有本身是素数,每一位是素数,各位相加的和还是素数,用函数实现 这个我想了一种,把不是素数的带上一个标记,最后判断时根据有无这个标记,这种方法的麻烦之处在于每个环节都要判断 同学提供了一种思路,用bool值去return,上次已经提到return可以终止一个函数体,对于素数性质十
阅读全文
posted @ 2020-12-16 00:20 empty_thought
阅读(85)
评论(0)
推荐(0)
2020年12月14日
递归函数实现阶乘
摘要: 万恶的期中考试和英语四级结束了,终于又能愉快地写博客啦。 函数递归可以执行循环的功能,控制量,初始量,变化量。 return函数的使用,将上一个函数的结果传递给这个函数,明白分步执行的需要完成的是什么,我对函数递归的理解还远远不够,以后多多做这种题 #include <stdio.h> #inclu
阅读全文
posted @ 2020-12-14 23:51 empty_thought
阅读(513)
评论(0)
推荐(0)
2020年12月7日
队列的C语言
摘要: 接下来的写法有线性队列的,也有循环队列,代码没有调试,可能运行时有问题 #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #define SIZE 6 int top=0; int rear=0; int array[SIZE]=
阅读全文
posted @ 2020-12-07 00:14 empty_thought
阅读(208)
评论(0)
推荐(0)
2020年12月2日
栈(外部变量的实现)
摘要: #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #define STACK_SIZE 10 int content[STACK_SIZE]; int top=0;//栈最高的位置 void make_empty(void) {
阅读全文
posted @ 2020-12-02 23:12 empty_thought
阅读(161)
评论(0)
推荐(0)
2020年12月1日
选择排序的勘误
摘要: 上次算法并不是本来的含义,特此修改,且这次算法对输出格式有比较麻烦的要求,代码较为繁琐 #include <stdio.h> int num;//最大数的下标 ,全局变量, int Max(int a[],int n)//这个算法找出前i个元素的最大值 { int max=a[0]; num=0;
阅读全文
posted @ 2020-12-01 00:17 empty_thought
阅读(65)
评论(0)
推荐(0)
2020年11月30日
接上篇:基数排序
摘要: #include <stdio.h> #include <stdlib.h> void RadixCountSort(int b[],int a[],int n) //这个是计数算法,只是count[]范围在0到1 { int i; int count[10]={0}; for(i=0;i<10;i
阅读全文
posted @ 2020-11-30 00:14 empty_thought
阅读(77)
评论(0)
推荐(0)
排序算法之快速排序、计数排序
摘要: #include <stdio.h> #include <stdlib.h> #include <stdbool.h> //快速排序算法,一个是递归,一个就是之前的分割算法 void Quick_sort(int a[],int high,int low); int split(int a[],in
阅读全文
posted @ 2020-11-30 00:13 empty_thought
阅读(122)
评论(0)
推荐(0)
2020年11月29日
排序算法之选择排序、冒泡排序、插入排序、折半插入排序、归并排序
摘要: #include <stdio.h> //交换数字 ,这里如果不用指针就会导致数值只会在函数体里交换 void swap(int* x, int* y) { int mid; mid = *x; *x = *y; *y = mid; } //选择排序 void Selection_sort(int
阅读全文
posted @ 2020-11-29 00:18 empty_thought
阅读(86)
评论(0)
推荐(0)
2020年11月26日
打印不重复数字
摘要: 给出N个数,要求把其中重复的去掉,只保留第一次出现的数。 例如,给出的数为1 2 18 3 3 19 2 3 6 5 4,其中2和3有重复,去除后的结果为1 2 18 3 19 6 5 4。 输入 输入第一行为正整数T,表示有T组数据。 接下来每组数据包括两行,第一行为正整数N,表示有N个数。第二行
阅读全文
posted @ 2020-11-26 23:41 empty_thought
阅读(236)
评论(0)
推荐(0)
上一页
1
···
5
6
7
8
9
10
下一页
公告
点击右上角即可分享