- 博客(6)
- 收藏
- 关注
原创 6.用插入排序对任意一组随机数据进行随机数组进行排序(用循环和递归两种方法)
//6.用插入排序对任意一组随机数据进行随机数组进行排序(用递归和循环两种方法写) /* 插入排序适合边插入边排序 思想:将每个数向后移动 解题步骤: 1.循环条件的判断 2.将前面的数向后移动一位 3.将要交换的数跟未移动前面的数进行比较,如果适合条件交换就交换,否则不交换, 4.重复步骤2,3 */ //模拟插入 模拟插入排序 #include #includ
2015-07-14 11:14:10
856
原创 5.斐波那契数组:循环和递归;输入n时判断该数是几:(for循环和递归写) 1 1 2 3 5 8 13 21 34
/* 1.斐波那契数组:循环和递归;输入n时判断该数是几 1 1 2 3 5 8 13 21 34 */ //递归 #include int fun(int n) { if (n == 1 || n == 2) { return 1; } return fun(n - 1) + fun(n - 2); } void main() { int num;
2015-07-14 11:08:18
923
原创 //4.创建一个20个大小的随机数组,用冒泡法对其进行排序(用for while 递归三种方式对其进行排序)
//4.创建一个20个大小的随机数组,用冒泡法对其进行排序(用for while 递归三种方式对其进行排序) //第一种(for循环) #include #include #define N 20 void main() { //先进行数组的初始化 time_t ts; unsigned int data = time(&ts); srand(data);//建立
2015-07-14 11:02:21
1278
原创 3.创建一个20个大小的随机数组,找出这组数组的最大值和最小值, 并且标出最大数和最小值的位置
// 3.创建一个20个大小的随机数组,找出这组数组的最大值和最小值, 并且标出最大数和最小值的位置 #include #include void main3() { int a[20]; time_t ts; int Max, Min, temp; int Minpos, MaxPos; unsigned int data = time(&ts); s
2015-07-14 10:50:27
1596
原创 2.创建一个20个大小的随机数组,然后输入一个数,判断是否存在这个数
//2.创建一个20个大小的随机数组,然后输入一个数,判断是否存在这个数 #include #include void main() { int num; time_t ts; unsigned int data = time(&ts); srand(data);//创建一个随机种子 int a[20]; scanf_s("%d", &num); for (int i
2015-07-14 10:47:49
851
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅