首页 > 代码库 > 第二次作业
第二次作业
#include<stdio.h> int main() { void swap(int *p1,int *p2); int a,b; int *pointer_1,*pointer_2; scanf("%d%d",&a,&b); pointer_1=&a; pointer_2=&b; swap(pointer_1,pointer_2); printf("%d,%d\n",a,b); } void swap(int *p1,int *p2) { int n; n=*p1; *p1=*p2; *p2=n; }
总结:1、调用了一个swap函数,同是使用指针作为形参,实现两个数的交换,如果再加入一个if语句还可以实现输出较大,较小值。
2、主函数调用错误,函数类型没有弄清楚,过程中,两个值没有调换。编程过程中小错误太多,不太仔细,导致程序无法运行。
3、应该仔细认真,多看看课本,掌握好学习方法,多编程,熟悉c语言,对其不再陌生。多看看书上例题,认真消化,仔细钻研,争取做到最好。
第二次作业
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。