上一页 1 ··· 307 308 309 310 311 312 313 314 315 ··· 403 下一页
摘要: 1、c语言中函数的参数 01、c语言中实参向形参的传递过程是单向传递的,在对形参进行修改后的值不能返回给实参。 02、函数返回调用源的返回值只能有一个。 例、求两个数的和与差。 #include <stdio.h> void sum_diff(int x, int y, int sum, int d 阅读全文
posted @ 2021-05-30 12:12 小鲨鱼2018 阅读(1495) 评论(0) 推荐(0)
摘要: 1、 #include <stdio.h> void ary_set(int v[], int n, int val) { int i; for(i = 0; i < n; i++) { v[i] = val; } } int main(void) { int i; int a[5] = {1,2, 阅读全文
posted @ 2021-05-30 09:22 小鲨鱼2018 阅读(132) 评论(0) 推荐(0)
摘要: 函数间数组的传递,是以指向第一个元素的指针的形式进行的。 在被调用的函数中作为指针接收的数组, 实际上就是调用方传递的数组。 Type*型指针p指向Type型数组a的起始元素a[0]时, 指针p的行为就和数组a本身一样。 值: a[i] = *(a + i) = *(p + i) = p[i]; 指 阅读全文
posted @ 2021-05-30 08:32 小鲨鱼2018 阅读(67) 评论(0) 推荐(0)
摘要: c语言中指针运算符和下标运算符。 1、对于数组中任一元素 a[i], 一般由三个别名: *(a + i)、*(p + i)、p[i]。 其中p为指向数组第一个元素的指针(p + i 等价于 &a[i])。 对应的指针分别为: &a[i]、 a + i、p + i、&p[i]. 利用程序证明: a[i 阅读全文
posted @ 2021-05-29 22:25 小鲨鱼2018 阅读(1038) 评论(0) 推荐(0)
摘要: c语言中数组的名称原则上为数组的第一个元素的指针。(当sizeof和&应用数数组名除外)。 当p为第一个元素的指针时, p + i 为第一个元素后的第i个元素的指针,则 p + i等价于 &a[i]. 程序如下: #include <stdio.h> int main(void) { int i; 阅读全文
posted @ 2021-05-29 22:02 小鲨鱼2018 阅读(244) 评论(0) 推荐(0)
摘要: 1、 #include <stdio.h> void swap2(int *x, int *y) { int tmp; tmp = *x; *x = *y; *y = tmp; } void sort2(int *n1, int *n2, int *n3) { if(*n1 > *n2) //将前两 阅读全文
posted @ 2021-05-29 16:24 小鲨鱼2018 阅读(76) 评论(0) 推荐(0)
摘要: c语言中两个值的排序,指针在函数间的传递。 1、 #include <stdio.h> void sap(int *x, int *y) { int tmp; tmp = *x; *x = *y; *y = tmp; } void sort2(int *n1, int *n2) // n1和n2为指 阅读全文
posted @ 2021-05-29 14:09 小鲨鱼2018 阅读(212) 评论(0) 推荐(0)
摘要: 1、last day (错误程序) #include <stdio.h> void lastday(int *y, int *m, int *d) { if(*d > 1) { *d -= 1; } if(*d == 1 && *m == 2 || *m == 4 || *m == 6 || *m 阅读全文
posted @ 2021-05-29 12:13 小鲨鱼2018 阅读(104) 评论(0) 推荐(0)
摘要: 1、 #include <stdio.h> void adjust(int *x) //声明指向int型的指针变量x { if(*x < 0) *x = 0; if(*x > 100) *x = 100; } int main(void) { int a, b, c; puts("please in 阅读全文
posted @ 2021-05-29 10:25 小鲨鱼2018 阅读(83) 评论(0) 推荐(0)
摘要: c语言中实现两个值互换的函数。 1、 #include <stdio.h> void swap(int n1, int n2) { int tmp; tmp = n1; n1 = n2; n2 = tmp; } int main(void) { int a, b; puts("please inpu 阅读全文
posted @ 2021-05-29 09:55 小鲨鱼2018 阅读(1621) 评论(0) 推荐(0)
上一页 1 ··· 307 308 309 310 311 312 313 314 315 ··· 403 下一页