A.同时在多个网络社区注册是没有必要的
B.盲目追逐新潮会耗费大量的精力和时间
C.网络社区应吸取免费电子邮箱热潮的教训
D.对未来网络社区规模的估计不宜盲目乐观
第1题
试题三(共 15 分)
阅读以下说明和 C 程序,将应填入 (n) 处的字句写在答题纸的对应栏内。
第2题
阅读下列程序说明和C++程序,把应填入其中(n)处的字句,写在对应栏内。
【说明】
阅读下面几段C++程序回答相应问题。
比较下面两段程序的优缺点。
①for (i=0; i<N; i++ )
{
if (condition)
//DoSomething
…
else
//DoOtherthing
…
}
②if (condition) {
for (i =0; i<N; i++ )
//DoSomething
}else {
for (i=0; i <N; i++ )
//DoOtherthing
…
}
第3题
阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。
[说明]
下面程序实现十进制向其它进制的转换。
[C++程序]
include"ioStream.h"
include"math.h"
include
typedef struct node {
int data;
node*next;
}Node;
Class Transform.
{
DUDlic:
void Trans(int d,int i); //d为数字;i为进制
void print();
private:
Node*top;
};
void Transform.:Trans(int d,int i)
{
int m,n=0;
Node*P;
while(d>0)
{
(1);
d=d/i;
p=new Node;
if(!n){
p->data=m;
(2);
(3);
n++;
}
else{
p->data=m;
(4);
(5);
}
}
}
void Transform.:print()
{
Node*P;
while(top!=NULL)
{
p=top;
if(p->data>9)
cout<<data+55;
else
cout<<data;
top=p->next;
delete p;
}
}
第4题
() 阅读下列说明和JAVA代码,将应填入空(n)处的字句写在答题纸的对应栏内。【说明】 某中学开展中外中学生野外生存夏令营活动,由于中外学生的语言障碍,随队为外籍学员配置一名翻译。以下代码采用适配器(Adapter)模式模拟翻译适配器。其类图如下:
第5题
阅读以下说明和流程图,将应填入(n)处的字句写在对应栏内。
【说明】
已知头指针分别为La和lb的有序单链表,其数据元素都是按值非递减排列。现要归并La和Lb得到单链表Lc,使得Lc中的元素按值非递减排列。程序流程图如下所示:
第6题
阅读以下说明和Java代码,将应填入(n)处的字句写在对应栏内。
【说明】
下面程序完成从键盘读入一个字符串,然后采用parseInt方法将其转换为一个相应的整数。
import java.io.*;
public class testThrows{
public static (1) readString() (2) IOException{
int ch;
String r="";
boolean done=false;
while((3)){
ch=System.in.read();
if(ch<0 || ch=0xd) //处理回车符中第一个符号
done=true;
else
r=r+(char)ch;
}
return r;
}
public static void main(Stling args[]){
String str;
(4) {
str=readString();
} (5) (IOException e){
System.out.println("error");
return;
}
System.out.println("input integer: "+Integer.parselnt(str));
}
}
第7题
阅读下列Java程序和程序说明,将应填入(n)处的字句写在对应栏内。
【说明】StringEditor类的功能是:已知一个字符串,返回将字符串中的非字母字符都删除后的字符串。
public (1) {
public static String removeNonLetters((2) ){
StringBuffer aBuffer=(3);
char aCharacter;
for(int i=0; i<original.length();i++){
aCharacter=(4);
if(Character.isLetter(aCharacter))
aBuffer.append((5) );
}
return new String(aBuffer);
}
}
public class StringEditorTester{
public static void main(String args[]){
String riginal="Hi!, My Name is Mark, 234I think you are my classmate?!!";
System.out.println(StringEditor.removeNonLetters(original));
}
}
第8题
阅读以下说明、Java代码,将应填入(n)处的字句写在对应栏内。
【说明】
本程序输出10000之内的所有完全数。完全数是指等于其所有因子和(包括1,但不包括这个数本身)的数。例如:6=1×2×3,6=1+2+3,则6是一个完全数。
【程序】
public class PerfectNum
{
Public static void main(String args[])
{
int count=1;
for(int i=1; i<10000; i++)
{
int y=0;
for(int j=1; j<i; j++)
if((1))
y=(2)
if((3))
{
System.out.print((4) +String.valueOf('\t'));
(5)
If(count%3==0)
System.out.printin();
}
}
}
第9题
阅读以下说明和JAVA 2代码,将应填入(n)处的字句写在对应栏内。
[说明]
以下程序为类类型的变量应用实例,通过异常处理检验了类CCircle的变量的合法性,即参数半径应为非负值。仔细阅读代码和相关注释,将程序补充完整。
[JAVA代码]
//定义自己的异常类
class CCircleException extends Exception
{
}
// 定义类 CCircle
class CCircle
{
private double radius;
public void setRadius (double r ) (1)
{
if (r<0 ) {
(2)
}
else
(3)
}
Public void show () {
System. out. println ("area="+3.14*radius*radius );
}
}
public class ciusample
{
public static void main (String args[] )
{
CCircle cir=new CCircle();
(4) {
cir. setRadius (-2.0 )
}
(5)
{
System. out. println (e+" throwed" ) ;
}
cir. show() ;
}
}
第10题
阅读以下说明和Java代码,将应填入(n)处的字句写在对应栏内。
【说明】
下面程序完成从键盘读入一个字符串,然后采用parseInt方法将其转换为一个相应的整数。
import java.io.*;
public class testThrows{
public static (1) readString() (2) IOException{
int ch;
String r="";
boolean done=false;
while((3)){
ch=System.in.read();
if(ch<0 || ch=0xd) //处理回车符中第一个符号
done=true;
else
r=r+(char)ch;
}
return r;
}
public static void main(Stling args[]){
String str;
(4) {
str=readString();
} (5) (IOException e){
System.out.println("error");
return;
}
System.out.println("input integer: "+Integer.parselnt(str));
}
}
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!