1、第六章单选若已定义char s10;则在下面表达式中不表示s1的地址是( ) 。A.p=a ; while (*p!=u) printf(“%c”,*p-32); p+ ; A.languageB.langUAGEC.LANGUAGED.LANG下面能正确进行字符串赋值操作的是( )A.char s5=A,B,C,D,E;B.char s5=“ABCDE“;C.char *s ; s=“ABCDE“ ;D.char *s; scanf(“%s“,s) ;设p1和p2是指向同一个字符串的指针变量,c为字符变量,则以下能正确执行并得到有意义的结果的赋值语句是( )。A.p2=c;B.c=*p1+*
2、p2;C.p1=p2;D.c=*p1*(*p2);已有函数max(a,b),为了让函数指针变量p指向函数max,正确的赋值方法是( )。A.*p=max(a,b);B.*p=max;C.p=max;D.p=max(a,b);以下正确的叙述是( )。A.C语言允许main函数带形参,且形参个数和形参名均可由用户指定B.当main函数带有形参时,传给形参的值只能从命令行中得到C.若有说明: int main(int argc,char *argv),则argc的值必须大于1D.C语言允许main函数带形参,形参名只能是argc和argv若有定义:int (*p)4;则标识符p( )。A.是一个指针
3、数组名B.定义不合法C.是一个指向整型变量的指针D.是一个指针,它指向一个含有四个整型元素的一维数组设有程序段:char s =“china“; char *p ; p=s ;则下面叙述正确的是() 。A.*p与s0相等B.数组s中的内容和指针变量p中的内容相等C.s数组长度和p所指向的字符串长度相等D.s和p完全相同下面程序段的运行结果是( )。char *s=”abcde” ;s+=2 ; printf(“%s”,s);A.字符c的地址B.不确定C.cdeD.字符c下面判断正确的是() 。A.char str10=“china“; 等价于 char str10; str =“china“;
4、B.char c4=“abc“,d4=“abc“; 等价于 char c4=d4=“abc“ ;C.char *a=“china“; 等价于 char *a; *a=“china“ ;D.char *s=“china“; 等价于 char *s; s=“china“ ;设有程序段:char s =”china” ; char *p ; p=s ;则下面叙述正确的是( )A.数组s中的内容和指针变量p中的内容相等B.*p与s0相等C.s数组长度和p所指向的字符串长度相等D.s和p完全相同已有变量定义和函数调用语句:int a=25;print_value(下面函数的输出结果是( )void pr
5、int_value(int *x) printf(“%dn”,+*x); A.24B.23C.25D.26若有说明:int *p,m=5,n;以下程序段正确的是( )A.p = *p = m ;B.p=scanf(“%d“,C.p = scanf(“%d“,*p);D.scanf(“%d“, *p=n ;变量的指针,其含义是指该变量的( )A.值B.地址C.一个标志D.名已有定义int k=2;int *ptr1,*ptr2;且ptr1和ptr2均已指向变量k,下面不能正确执行的赋值语句是( )A.ptr2=k;B.k=*ptr1+*ptr2;C.k=*ptr1*(*ptr2);D.ptr1=
6、ptr2程序设计/*请编写函数fun,该函数的功能是:判断字符串是否为回文,若是则函数返回1,主函数中输出“YES“,否则返回0,主函数中输出“NO“。回文是指顺读和倒读都一样的字符串。例如,字符串LEVEL是回文,而字符串123312就不是回文。注意:部分源程序给出如下。请勿改动main函数和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。试题程序:*/#include #define N 80int fun(char str)/*Begin*/* End */void main()char sN;FILE *out;char test80=“1234321“,“1234
7、21“,“123321“,“abcdCBA“;int i;printf(“Enter a string : “);gets(s);printf(“nn“);puts(s);if(fun(s)printf(“YESn“);elseprintf(“NOn“); /*/out=fopen(“debugout12.dat“,“w“);for(i=0;i#include#define N 80int fun(char *s)/*Begin*/*End*/void main() FILE *wf;char lineN; int num=0;printf(“Enter a string:n “); gets
8、(line);num=fun(line);printf(“The number of word is:%dnn “,num);/*/wf=fopen(“d:out19.dat“,“w“);fprintf(wf,“%d“,fun(“This is a big car“);fclose(wf);/*/【参考代码】int i,j=0; for(i=0;si!=0;i+)if(si!= return j;/*返回单词个数*/ /*假定输入的字符串中只包含字母和*号。请编写函数fun,它的功能是:除了字符串前导的*号之外,将串中其他*号全部删除。在编写函数时,不得使用C语言提供的字符串函数。 例如,若字
9、符串中的内容为*A*BC*DEF*G*,删除后,字符串中的内容则应当是*ABCDEFG。 注意:部分源程序给出如下。 请勿改动main函数和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。 试题程序: */#include #include void fun (char *a)/*Begin*/*End*/void main()char s81;FILE *in,*out;int i;printf(“Enter a string :n“);gets(s);fun(s);printf(“The string after deleted:n“);puts(s);/*/in=fo
10、pen(“in21.dat“,“r“);out=fopen(“debugout21.dat“,“w“);for(i=0;ivoid fun (char *a)/*Begin*/*End*/void main()FILE *wf,*in;int i;char s81,t81=“*A*BC*DEF*G*“;printf(“Enter a string :n“);gets(s);fun(s);printf(“The string after deleted:n“);puts(s);/*/in=fopen(“in18.dat“,“r“);wf=fopen(“debugout18.dat“,“w“);f
11、or(i=0;i#include #define N 81void fun(char*s)/*Begin*/*End*/void main()char aN;FILE *out;printf(“Enter a string:“);gets(a);printf(“The original string is:“);puts(a);fun(a);printf(“n“);printf(“The string after modified:“);puts(a);strcpy(a,“Hello World! This is a first C program!“);fun(a);/*/out=fopen
12、(“d:out17.dat“,“w“);fprintf(out,“%s“,a);fclose(out);/*/【参考代码】char ch; int i,m,n; i=0; m=n=strlen(s)-1; while(i#include void fun(int a ,int b,long *c)/*Begin*/*End*/void main()int a,b; long c;FILE *out;printf(“Input a ,b: “);scanf(“%d%d“,fun(a,b,printf(“The result is :%ldn“,c);/*/out=fopen(“debugout20.dat“,“w“);for(a=10;a20;a+)fun(a,109-a,fprintf(out,“%dn“,c);fclose(out);/*/【参考代码】*c=(a/10)*1000+(b/10)*100+(a%10)*10+b%10;