上一页 1 ··· 301 302 303 304 305 306 307 308 309 ··· 367 下一页
摘要: 1、c语言中分支结构程序 switch语句的经典用法。 #include <stdio.h> int main(void) { int i; puts("please input an integer."); printf("i = "); scanf("%d", &i); switch(i % 3 阅读全文
posted @ 2021-04-06 21:07 小鲨鱼2018 阅读(740) 评论(0) 推荐(0) 编辑
摘要: 1、 非函数形式 #include <stdio.h> int main(void) { int a[4][3] = {{54,63,14},{65,85,78},{85,74,69},{25,65,78}}; int b[4][3] = {{25,65,74},{85,74,96},{25,87, 阅读全文
posted @ 2021-03-31 18:55 小鲨鱼2018 阅读(1831) 评论(0) 推荐(0) 编辑
摘要: 创建一个函数,将和有n个元素的数组中的key相等的所有元素的下标存储在另一个数组中,并返回和key元素相同的元素的个数。 1、数组元素的查找 #include <stdio.h> #define NUMBER 10 int func1(const int x[], int y[], int z, i 阅读全文
posted @ 2021-03-31 18:36 小鲨鱼2018 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 创建一个函数,将和有n个元素的数组中的key相等的所有元素的下标存储在另一个数组中,并返回和key元素相同的元素的个数。 1、数组元素的查找 #include <stdio.h> #define NUMBER 10 int func1(const int x[], int y[], int z, i 阅读全文
posted @ 2021-03-31 17:26 小鲨鱼2018 阅读(94) 评论(0) 推荐(0) 编辑
摘要: c语言中数组元素的哨兵查找法,用于查找数组中是否存在特定的元素,如果存在,就返回目标元素的索引。 像对于线性查找法,哨兵查找法可以减少程序进行判断的次数。 在数组末尾追加的数据称为哨兵。 1、 #include <stdio.h> #define NUMBER 7 #define FAILED -1 阅读全文
posted @ 2021-03-31 11:29 小鲨鱼2018 阅读(941) 评论(0) 推荐(0) 编辑
摘要: c语言中数组元素的线性查找。 1、再数组中查找特定的元素,并返回查找的索引。 #include <stdio.h> #define NUMBER 7 #define FAILED -1 int func1(const int x[], int y, int z) { int i = 0; while 阅读全文
posted @ 2021-03-31 10:48 小鲨鱼2018 阅读(517) 评论(0) 推荐(0) 编辑
摘要: 创建一个函数,对元素个数为n的int型数组进行倒序排列,并将结果保存到另一个数组中。 1、 #include <stdio.h> #define NUMBER 9 void func1(int x[], const int y[], int z) { int i; for (i = 0; i < z 阅读全文
posted @ 2021-03-30 22:39 小鲨鱼2018 阅读(261) 评论(0) 推荐(0) 编辑
摘要: 创建一个函数,对元素个数为n的int型数组进行倒序排列 1、 #include <stdio.h> #define NUMBER 9 void func1(int x[], int y) { int i; for (i = 0; i < y / 2; i++) { int tmp = x[i]; x 阅读全文
posted @ 2021-03-30 22:26 小鲨鱼2018 阅读(259) 评论(0) 推荐(0) 编辑
摘要: 1、创建一个函数,返回元素个数为n的int型数组中的最小值 #include <stdio.h> #define NUMBER 7 int func1(const int x[], int y) { int i, min = x[0]; for (i = 0; i < y; i++) { if (x 阅读全文
posted @ 2021-03-30 21:54 小鲨鱼2018 阅读(286) 评论(0) 推荐(0) 编辑
摘要: c语言中函数的传递和const类型的修饰符。 c语言中函数的传递:对接受到的数组元素进行的修改,元素值的变化也会反映到再次调用时传入的数组中。 const类型的修饰符:在给函数传递数组时,如果担心传递给函数的数组的元素会被修改,只要在声明形参的时候加上被称为const的类型修饰符就可以了。 如果只是 阅读全文
posted @ 2021-03-30 21:31 小鲨鱼2018 阅读(202) 评论(0) 推荐(0) 编辑
上一页 1 ··· 301 302 303 304 305 306 307 308 309 ··· 367 下一页