#include sub1(char a,char b) {char c;c=a;a=b;b=c;} sub2(char *a,char b) {char c;c=*a;*a=b;
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/22 13:18:42
#include sub1(char a,char b) {char c;c=a;a=b;b=c;} sub2(char *a,char b) {char c;c=*a;*a=b;
#include sub1(char a,char b) {char c;c=a;a=b;b=c;} sub2(char *a,char b) {char c;c=*a;*a=b;
#include sub1(char a,char b) {char c;c=a;a=b;b=c;} sub2(char *a,char b) {char c;c=*a;*a=b;
你要问的是这个吧...我也在做这个
# include "stdio.h"
void sub1(char a,char b)
{ char c; c=a; a=b; b=c; }
void sub2(char *a,char b)
{ char c; c=*a; *a=b; b=c; }
void sub3(char *a,char *b)
{ char c; c=*a; *a=*b; *b=c; }
void main()
{ char a,b; a='A'; b='B';
sub3(&a,&b); putchar(a); putchar(b);
sub2(&a,b); putchar(a); putchar(b);
sub1(a,b); putchar(a); putchar(b);
}
答案是BAAAAA
sub3(&a,&b);a,b交换值,得a = 'B',b = 'A';
sub2(&a,b);b的值再赋给a,得a = 'A',b作为形参,值不变,b = 'A'
sub1(a,b);a,b都为形参,a,b的值都不变,a= 'A',b = 'A'.