上一页 1 ··· 312 313 314 315 316 317 318 319 320 ··· 407 下一页
摘要: 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)
摘要: c语言中指针作为参数的函数同时计算两个数的和与差。 1、 #include <stdio.h> void sum_dif(int n1, int n2, int *sum, int *dif) { *sum = n1 + n2; *dif = (n1 > n2) ? (n1 - n2) : (n2 阅读全文
posted @ 2021-05-28 23:13 小鲨鱼2018 阅读(1371) 评论(0) 推荐(0)
摘要: c语言中将指针作为函数的参数。 1、 #include <stdio.h> void fun(int *x) { if(*x < 170) // 指向特定对象的指针,在使用指针运算符的时候就是该对象的别名,对别名进行重新赋值,可以传递给main函数。 { *x = 1000; } } int mai 阅读全文
posted @ 2021-05-28 22:24 小鲨鱼2018 阅读(408) 评论(0) 推荐(0)
摘要: c语言中指针 1、 #include <stdio.h> int main(void) { int a = 100; int b = 200; int c = 300; int *x, *y; x = &a; y = &c; printf("xxxx: %d\n", *x); printf("yyy 阅读全文
posted @ 2021-05-28 16:52 小鲨鱼2018 阅读(115) 评论(0) 推荐(0)
上一页 1 ··· 312 313 314 315 316 317 318 319 320 ··· 407 下一页