以下程序的输出结果是
#include"stdio.h"
sub1(chara,charb){charc;c=a;a=b;b=c;}
sub2(char*a,charb){charc;c=*a;*a=b;b=c;}
sub3(char*a,char*b){charc;c=*a;*a=*b;*b=c;}
main()
{chara,b;
a='A';b='B';sub3(&a,&b);putchar(a);putchar(b);
a='A';b='B';sub2(&a,b);putchar(a);putchar(b);
a='A';b='B';sub1(a,b);putchar(a);putchar(b);
}
#include"stdio.h"
sub1(chara,charb){charc;c=a;a=b;b=c;}
sub2(char*a,charb){charc;c=*a;*a=b;b=c;}
sub3(char*a,char*b){charc;c=*a;*a=*b;*b=c;}
main()
{chara,b;
a='A';b='B';sub3(&a,&b);putchar(a);putchar(b);
a='A';b='B';sub2(&a,b);putchar(a);putchar(b);
a='A';b='B';sub1(a,b);putchar(a);putchar(b);
}
举一反三
- 下列程序输出的结果是( )。#includefunl(chara,charb){charC;c=a;a=b;b=C;)fun2(char*a,charb){charC;c=*a;*a=b;b=c;)fun3(char*a,char*b){charC;C=*a;*a=*b;*b=C;)voidmain( ){chara,b;a='A';b='B';fun1(a,b);putchar(a);putchar(b);a='A';b='B';fun2(&a,b);putchar(a);putchar(b);a='A';b='B';fun3(&a,&b);putchar(a);putchar(b);putchar('\n');}[1分]
- 有以下程序 #include<stdio.h> sub1(char a,char B) char c;c=a;a=b;b=c; sub2(char *a,char B) char c;c=*a;*a=b;b=c; sub3(char *a,char *B) char c;c=*a;*a=*b;*b=c; main() cha,a,b; a=’A’;b=’B’;sub3(&a,&b) putchar( A: ;putchar( B: ; C: a=’A’;
- 读程序写结果。( ) #include“stdio.h” main() { char a,b,c; a=‘B’;b=‘O’; c=‘Y’; putchar(a); putchar(b); putchar(c); putchar(‘’);printf(“”);}
- 下列程序输出的结果是()。 #include<stdio.h> un1(char a,char b){char c;c=a;a=b;b=c;} fun2(char*a,char b){char c;c=*a;*a=b;b=c;} fun3(char*2,char*b){charc;c=*a;*a=*b;*b=c;} void main() { char a,b; a='A';b='B';funl(a,b);putchar(a);putchar(b); A: BABBAB B: ABBBBA C: ABBABA D: ABABBA
- 以下程序的输出结果是_____ 。 #include "stdio.h" main() { char b[]="ABCDEFG", *chp=&b[7]; while(--chp >&b[0]) putchar(*chp); putchar(' '); }