以下程序 #include<string.h> main(){ char a1,a2,*s1=a1,*s2=a2; gets(s1);gets(s2) if(!strcmp(s1,s2))printf("*"); else printf("#"); printf("%d",strlen(strcat(s1,s2))); } 如果从键盘上输入: book<回车> book<空格><回车> 则输出结果是
A.*8
B.#9
C.#6
D.*9
B、#9
A.*8
B.#9
C.#6
D.*9
B、#9
第1题
有以下程序
#include<stdio.h>
#include<string.h>
main()
{char x[]=“STRING”;
x[0]=0;x[1]=’\0’;x[2]=’0’;
printf(”%d%d\n”,sizeof(x),strlen(x));
}
程序运行后的输出结果是()。
A.6 1
B.7 0
C.6 3
D.7 1
第2题
给定以下程序段
insert code public class foo {
public static void main (String[] args) throws Exception {
printWriter ut = new PrintWriter (new java.io.outputStreamWriter (System.out), true) ;
out.printIn(“Hello”);
}
}
要使程序能正确运行,在insert code处必须添加()语句。
A、import java.io.PrintWriter;
B、include java.io.PrintWriter;
C、import java.io.OutputStreamWriter;
D、include java.io.OutputStreamWriter;
第3题
下列给定程序中函数fun()的功能是:求出字符串中最后一次出现的子字符串的地址,通过函数值返回,在主函数中输出从此地址开始的字符串;若未找到,则函数值为NULL。例如,当字符串中的内容为abcdabfabcdx,t中的内容为ab时,输出结果应是abcdx。当字符串中的内容为abcdabfabcdx,t中的内容为abd时,则程序输出未找到的信息:Not found!
请改正程序中的错误,使它能得出正确的结果。
注意;不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
include<stdio.h>
include <conio.h>
include <string.h>
char *fun(char *s,char *t)
{
char *p,*r,*a;
/*************found**************/
a=Null;
while(*s)
{ p=s;r=t;
while(*r)
/*************found**************/
if(r= =p) {r++;p++;}
else break;
if(*r=='\0') a=s;
s++;
}
return a;
}
main()
{char s[100],t[100],,*p;
clrscr();
printf("\nPlease enter string S: ");
scanf("%s",s);
printf("\nPlease enter substring t: ");
scanf("%s",t);
p=fun(S,t);
if(p) printf("\nThe result is:%s\n",p);
else printf("\nNot found!\n ");
}
第4题
请编写函数fun(),其功能是:将s所指字符串中下标为偶数的字符删除,串中剩余字符形成的新串放在t所指数组中。
例如,当s所指字符串中的内容为ABCDEFGHIJK,则在t所指数组中的内容应是BDFHJ。
注意:部分源程序给出如下。
请勿改动主函数main口其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。
试题程序:
include<conio. h>
include<stdio .h>
include<string.h>
void fun(char *s,char t[])
{
}
main ()
char s[l00] ,t[l00];
clrscr ();
printf("%nPlease enter string S: ");
scanf("%s ",s);
fun(s,t);
prlntf("\nThe result is:%s\n ",t);
}
第6题
A.public void main(String args[]){}
B.public int main(String args[]){}
C.public static void main(String args[]){}
D.public static int main(String args[]){}
第8题
A.-1
B.Exception
C.1
D.0
第9题
A.Not equal
B.Equal
C.无输出
D.编译出错