摘要:
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
阅读(221)
评论(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
阅读(108)
评论(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
阅读(87)
评论(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
阅读(1637)
评论(0)
推荐(0)
摘要:
c语言中作为函数参数的指针。 1、 #include <stdio.h> void fun(int *x) //声明指向int型的指针变量 { if(*x < 200) { *x = 5000; } } int main(void) { int a = 100; int b = 140; int c 阅读全文
posted @ 2021-05-29 09:23
小鲨鱼2018
阅读(454)
评论(0)
推荐(0)
摘要:
c语言中利用函数同时返回两个数的和与差。 1、 #include <stdio.h> void sum_diff(int n1, int n2, int sum, int diff) { sum = n1 + n2; diff = (n1 > n2) ? (n1 - n2) : (n2 - n1); 阅读全文
posted @ 2021-05-29 09:12
小鲨鱼2018
阅读(1074)
评论(0)
推荐(0)
摘要:
1、单目运算符&为取址运算符,其作用是获取对象的地址,生成指向对象的指针,与其说是获取地址,不如说是生成指针。对象地址的转换说明为%p,其中的p为pointer的首字母。 #include <stdio.h> int main(void) { int n; double x; int a[3]; p 阅读全文
posted @ 2021-05-29 08:58
小鲨鱼2018
阅读(1506)
评论(0)
推荐(0)

浙公网安备 33010602011771号