第二次C语言作业
2013-03-17 21:38
190 查看
5-7
运行结果
5-10
运行结果
6-2
运行结果
6-3
运行结果
运行结果
5-10
运行结果
6-2
/*源程序:exp6_2.cpp*/ #include<stdio.h> void main() { void printfline(); int max(int a,int b); int x,y,z,d; printfline(); printf("input there number:\n"); scanf("%d%d%d",&x,&y,&z); d=max(x,y); d=max(d,z); printf("maxmaum=%d\n",d); } void printfline() { printf("there is a C program!\n"); } int max(int a,int b) { if(a>b)return a; else return b; }
运行结果
6-3
/*源程序:exp6_3.cpp*/ #include<stdio.h> void main() { void swap(int x,int y); int a,b; a=2,b=6; printf("调试前:a=%d,b=%d\n",a,b); swap(a,b); printf("调试后:a=%d,b=%d\n",a,b); } void swap(int x,int y) { int temp; printf("交换前:x=%d,y=%d\n",x,y); temp=x; x=y; y=temp; printf("交换后x=%d,y=%d\n",x,y); }
运行结果