BY
BT
YT
YE
第1题:
有以下程序: #include<stdio.h> void fun(char**p) { ++P;printf("%s\n",*p);} main() char*a[]={"Morning","Afternoon","Evening","Night"}; fun(A); } 程序的运行结果是( )。
A.Afternoon
B.fternoon
C.Morning
D.oring
第2题:
有以下程序 #include <stdio.h> int fun(char s[]) { int n=O; while(*s<='9'&&*s>='0') { n=10*n+*s-'0'; s++; } return (n); } main() { char s[10]={ '6', '1', '*', '4', '*', '9', '*', '0', '*'}; printf("%d\n",fun(s)); }
A.9
B.61490
C.61
D.5
第3题:
有以下程序
#include <stdio.h>
main()
{ char *s={"ABC"};
do
{ printf("%d",*s%10);s++;
}
while (*s);
}
注意 : 字母 A 的 ASCII 码值为 65 。程序运行后的输出结果是
A)5670
B)656667
C)567
D)ABC
第4题:
有以下程序 #include <stdio.h> void fun(char *t, char *s) { while(*t!=0) t++; while( (*t++ = *s++ )!=0 ); main() { char ss[10]="acc",aa[10]="bbxxyy"; fun(ss, aa); printff"%s,%s\n", ss,aa); 程序的运行结果是
A.accxyy, bbxxyy
B.acc, bbxxyy
C.accxxyy, bbxxyy
D.accbbxxyy, bbxxyy
第5题:
有以下程序: #include <stdio.h>void funl (char * p){ char * q; q=p; while( *q! ='\0') } (*q) ++;q++;}mains( ){ char a[ ] = { "Program" } , * p; p = &a[3]; fun1 (p); printf("% s \n" ,a);}程序执行后的输出结果是( )。
A.Prohsbn
B.Prphsbn
C.Progsbn
D.Program
第6题:
请编写函数fun(),其功能是:将s所指字符串中除了下标为偶数、同时ASCII码值为奇数的字符之外,其余的所有字符都删除,串中剩余字符所形成的一个新串放在t所指的数组中。
例如,若s所指字符串中的内容为ABCDEFG12345,其中字符B的ASCII码值为偶数,所在元素的下标为奇数,因此必须删除;而字符A的ASCII码值为奇数,所在数组中的下标为偶数,因此不应当删除,其他依次类推。最后t所指的数组中的内容应是ACEG。
注意:部分源程序给出如下。
请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include<conio.h>
include<stdio.h>
include<string.h)
void fun(char *s, char t[])
{
}
main()
{
char s[100],t[100];
clrscr();
printf("\nPlease enter string s:");
scanf("%s",s);
fun(s,t);
printf("\nThe result is: %s\n",t);
}
第7题:
有以下程序 #include <stdio.h> #include <string.h> void fun(char s[][10],int n) { char t; int i j; for (i=0; i<n-1; i++) for 0--i+l; j<n; j++) /*比较字符串的首字符大小,并交换字符串的首字符*/ if(s[i][0] > s[j][0]) { t = s[i][0]; s[i][0] = s[j][0]; s[j][0] = t;} } main() { char ss[5][10]= {"bcc", "bbcc", "xy", "aaaacc", "aabcc" }; fun(ss, 5); printf("%s,%s\n", ss[0],ss[4]); } 程序的运行结果是
A.xy, aaaacc
B.aaaacc,xy
C.xcc,aabcc
D.acc,xabcc
第8题:
(25)有以下程序
#include<stdio.h>
void fun(char *s)
{while(*s)
{ if(*s%2==0) printf(“%c”,*s);
s++;
}
}
main()
{ char a[]={“good”};
fun(a);printf(“\n”);
}
注意:字母a的ASCII码值为97,程序运行后的输出结果是
A)d B)go C)god D)good
第9题:
有以下程序 #include <stdio.h> void fun(char **p) { ++p; printf("%s\n",*p); } main() { char *a[]={"Moming","Afternoon","Evening","Night"}; fun(a); } 程序的运行结果是
A.Afternoon
B.fternoon
C.Morning
D.orning
第10题:
有以下程序: #include<stdio.h> void fun(char *a,char*B){while(*a=='*')a++; while(*b=*A){b++;a++;} } main() {char*s="****a*b****",t[80]; fun(s,t);puts(t); } 程序的运行结果是( )。
A.*****a*b
B.a*b
C.a*b****
D.ab