题目详情
当前位置:首页 > 计算机考试 > 中级软件设计师
题目详情:
发布时间:2023-10-01 12:53:29

[简答题]阅读下列程序说明和C程序,将应填入 (n) 处的字句写在答卷纸的对应栏内。 【程序说明】 该程序定义了两个子函数strsort和strmerge。它们分别实现了将一个字符串按字母顺序排序和将两个字符串合并排序,并删去相同字符。在主函数里,先输入两个字符串s1和s2,然后调用strsort函数对它们分别排序,然后调用strmerge函数将s1和s2合并,将合并后的字符串赋给字符串s3,最后输出字符串s3。 【程序】 #include <stdio.h> void strmerge(char *a,char *b,char *c) //将字符串a,b合并到字符串c { char t,*w; W=c; while( (1) ) { //找到字符串a,b当前字符中较小的字符 if(*a<*b) { t=-*a, (2) } else if(*a>*b) { t=*b; (3) } else //字符串a,b 当前字符相等 { t=-*a; a-H-; b-H-; } if( (4) ) //开始,可直接赋值 *w=t; else if(t!=*w) //如果a,b中较小的当前字符与c中当前字符不相等,才赋值 (5) } if(*a!=’/O’) //如果字符串a还没有结束,则将a的剩余部分赋给c while(*a!=’/0’) if(*a!=*w) { *(++w)=*a; a++; } else (6) if(*b!=",’/0’) //如果字符串b 还没有结束,则将 b 的剩余部分赋给 c while(*b !=’/0’) if(*b!=*w) { *(++w)=*b; b++; }

更多"阅读下列程序说明和C程序,将应填入 (n) 处的字句写在答卷纸的对应栏"的相关试题:

[简答题]试题八(15 分,每空3 分) 阅读以下说明和C++程序,将应填入 (n) 处的字句写在答题纸的对应栏内。 [说明] 下面程序的功能是计算并输出某年某月的天数。 [C++程序] #include using namespace std; (1) Month{Jan, Feb, Mar, Apr,May,Jun, Jul, Aug, Sep,Oct,Nov,Dec}; class Date{ public: Date(int year, Month m_month){ (2) = year; if(m_month< Jan || m_month > Dec) month = Jan; else month = m_month; }; ~Date( ){}; bool IsLeapYear( ){ return ((year % 4 == 0 && year % 100 != 0) || year % 400 ==0); }; int CaculateDays( ){ switch( (3) ){ case Feb:{ if( (4) ) return 29; else return 28; } case Jan: case Mar: case May: case Jul: case Aug: case Oct: case Dec: return 31; case Apr: case Jun: case Sep: case Nov: return 30; } }; private: int year; Month month; }; void main( ){ Date day(2000,Feb); cout << day. (5) ( ); }
[多项选择]阅读下列程序说明和C程序,将应填入 (n) 处的字句写在答卷纸的对应栏内。
【程序说明】
该程序定义了两个子函数strsort和strmerge。它们分别实现了将一个字符串按字母顺序排序和将两个字符串合并排序,并删去相同字符。在主函数里,先输入两个字符串s1和s2,然后调用strsort函数对它们分别排序,然后调用strmerge函数将s1和s2合并,将合并后的字符串赋给字符串s3,最后输出字符串s3。
【程序】
#include <stdio.h>
void strmerge(char *a,char *b,char *c) //将字符串a,b合并到字符串c

char t,*w;
W=c;
while( (1) )

//找到字符串a,b当前字符中较小的字符
if(*a<*b)

t=-*a,
(2)

else if(*a>*b)

t=*b;
(3)

else //字符串a,b 当前字符相等

t=-*a;
a-H-;
b-H-;

if( (4) ) //开始,可直接赋值
*w=t;
else if(t!=*w)
//如果a,b中较小的当前字符与c中当前字符不相等,才赋值
(5)

if(*a!=’/O’) //如果字符串a还没有结束,则将a的剩余部分赋给c
while(*a!=’/0’)
if(*a!=*w)

*(++w)=*a;
a++;

else
(6)
if(*b!=",’
[简答题]
阅读以下程序说明和C程序,将应填入(n)处的字句,写在对应栏内。
【程序说明】
某网络由n个端点组成,这些端点被物理地分成若干个分离的端点组。同一组内的两件端点i和j,它们或直接相连,或间接相连(端点i和端点j间接相连是指在这两件端点之间有一个端点相连序列,其中端点i和j分别与这相连序列中的某个端点直接相连)。网络的n个端点被统一编号为0,1,…,n-1。本程序输入所有直接相连的端点号对,分别求出系统各分离端点组中的端点号并输出。
程序根据输入的直接相连的两件端点号,建立n个链表,其中第i个链表的首指针为s[i],其结点是与端点i直接相连的所有端点号。
程序依次处理各链表。在处理s[i]链表中,用top工作链表重新构造s[i]链表,使s[i]链表对应系统中的一个端点组,其中结点按端点号从小到大连接。
【程序】
#inelude
#define N 100
typeef struct node{
int data;
struct node *link;
}NODE;
NODE * s[N];
int i,j,n,t;
NODE *q,*p,*x,*y,*top;
main( )
{
printf(“Enter namber of components.”);
scanf(“%d”,&n);
for(i=0;i<n;i++) printf(“Enter pairs./n”);
while(scanf(“%d%d”,&i,&j)==2)
{ /*输入相连端点对,生成相连端点结点链表*/
p=(NODE*)malloc(sizeof(NODE));
p→data=j;p→link=s[i];s[i]=p;
p=(NODE*)malloc(sizeof(NODE));
p→data=i;p→link=s[j];s[j]=p;
}
for(i=0;i<n;i++) /*顺序处理各链表*/

[填空题]阅读以下说明和Java程序,将应填入 (n) 处的字句写在对应栏内。 [说明] 下面程序是为汽车市场编制的一个程序的一部分。其中automobile是基类。 [Java程序] class MainJava{ public static void main(String agr[]){ car sedan=new car( ); sedan.initialize(24,20.0,4); System.out.println ("The sedan can travel" + (1) +"miles./n"); System.out.println ("The sedan has" + (2) +"doors./n"); } } class automobile{ protected int miles_per_gallon; //汽车每加仑行驶公里数 (3) double fuel_capacity; //油箱容积 public void initialize(int in_mpg,int in_fuel){ miles_per_galion=in_mpg; fuel_capacity=in_fuel; } public int get_mpg( ){//提供一辆特定汽车每加仑公里数 return miles_per_gallon; } public double get_fuel( ){//提供油箱容积 return fuel_capacity; } public double travel_distance( ){//计算满油箱情况下的可行驶总公里数 return (4) ; } } class car (5) { private int Total_doors; public void initialize(int in_mpg,double in_fuel,int doors){ Total_doors=doors; miles_per_gallon=in_mpg;
[填空题]阅读以下说明和Java程序,将应填入 (n) 处的字句写在对应栏内。
[说明]
下面程序实现十进制向其它进制的转换。
[Java程序]
ClasS Node
int data;
Node next;class Transform
private Node top;
public void print( )
Node p;
while(top!=null)
P=top;
if(P.data>9)
System.out.print((char)(P.data+55));
else
System.out.print(p.data);
top=p.next;


public void Trans(int d,int i)//d为数字;i为进制
int m;
(1) n=false;
Node p;
while(d>0)
(2) ;
d=d/i;
p=new Node( );
if( (3) )
p.data=m;
(4) ;
top=P;
n=true;

else
p.data=m;
(5)
top=P;




[填空题]阅读以下说明和Java程序,将应填入 (n) 处的字句写在对应栏内。
[说明]
下面程序输出一个矩形面积,以及矩形区域上的假想的作物产量。
[Java程序]
public class MainJava
public static void main(String[] args)
Lot_size small=new Lot_size( );
Lot_size medium=new Lot_size( );
small.set(5,5,5,25);
medium.set(10,10,10,50);
System.out.println("For a small lot of area"
+small.get_area( )+"/n");
System.out.println("the actual crops are $"
+small.get_data2( )+"/n");
System.out.println("and ideal crops are $"
+small.get data( )+"/n");
System.out.println("For a medium lot of area"
+medium.get_area( )+“/n”);
System.out.println("the actual crops are $"
+medium.get_data2( )+"/n");
System.out.println ("and ideal crops are $"
+medium.get_data( )+"/n");
class Crop_assessment
private int actual_crop;
private int ideal_crop;
public void set(int
[简答题]
阅读下列说明和C++程序,将应填入(n)处的字句写在对应栏内。
【程序1说明】
程序1中定义了数组的类模板,该模板使得对于任意类型的二维数组,可以在访问数组元素的同时,对行下标和列下标进行越界判断,并给出相应的提示信息(C++语言本身不提供对下标越界的判断)。
【程序1】
#include < iostream. h >
template < class T > class Array2D;
template < class T > class Array2DBody {
friend (1) ;
T * tempBody;
int iRows, iColumns, iCurrentRow;
Array2DBody(int Rows,int Cols) {
tempBody = (2) ;
iRows = Rows;
iColumns = Cols;
iCurrentRow = -1;
}
public:
T& operator[ ] (int j){
bool row_ error, column_ error;
row_ error = column_ error = false;
try {
if ( iCurrentRow < 0||iCurrentRow > = iRows)
row_ error = true;
if( j < 0||j > = iColumns)
column_error = true;
if( row_error = = true [ [ column_ error = = true)
(3) ;
}
catch(char) {
if (row_error = = true)
cerr < < "行下标越界"[" < < iCurrentRow < < "]";

[填空题]阅读以下说明和Java程序,将应填入 (n) 处的字句写在对应栏内。
[说明]
下面程序输出一个矩形面积,以及矩形区域上的假想的作物产量。
[Java程序]
public class MainJava {
public static void main(String[] args){
Lot_size small=new Lot_size( );
Lot_size medium=new Lot_size( );
small.set(5,5,5,25);
medium.set(10,10,10,50);
System.out.println("For a small lot of area"
+small.get_area( )+"/n");
System.out.println("the actual crops are $"
+small.get_data2( )+"/n");
System.out.println("and ideal crops are $"
+small.get data( )+"/n");
System.out.println("For a medium lot of area"
+medium.get_area( )+“/n”);
System.out.println("the actual crops are $"
+medium.get_data2( )+"/n");
System.out.println ("and ideal crops are $"
+medium.get_data( )+"/n");
}
}
class Crop_assessment{
private int actual_crop;
private int ideal_crop;
public void set(int in_actual,in
[填空题]阅读以下说明和Java程序,将应填入 (n) 处的字句写在对应栏内。
[说明]
下面程序是为汽车市场编制的一个程序的一部分。其中automobile是基类。
[Java程序]
class MainJava
public static void main(String agr[])
car sedan=new car( );
sedan.initialize(24,20.0,4);
System.out.println ("The sedan can travel"
+ (1) +"miles./n");
System.out.println ("The sedan has"
+ (2) +"doors./n");


class automobile
protected int miles_per_gallon; //汽车每加仑行驶公里数
(3) double fuel_capacity; //油箱容积
public void initialize(int in_mpg,int in_fuel)
miles_per_galion=in_mpg;
fuel_capacity=in_fuel;

public int get_mpg( )//提供一辆特定汽车每加仑公里数
return miles_per_gallon;

public double get_fuel( )//提供油箱容积
return fuel_capacity;

public double travel_distance( )//计算满油箱情况下的可行驶总公里数
return (4) ;


class car (5)
private int Total_doors;
public void initialize(int in_mpg
[填空题]阅读以下说明和Java程序,将应填入 (n) 处的字句写在对应栏内
[说明]
以下程序的功能时三角形、矩形和正方形的面积输出。
程序由5个类组成:areatest是主类,类Triangle,Rectangle和Square分别表示三角形、矩形和正方形,抽象类Figure提供了一个计算面积的抽象方法。
[Java程序]
public class areatest {
public static viod main(string args[]){
Figure[]Figures={
New triangle(2,3,3),new rectangle(5,8),new square(5)
};
for(int i=0; i<Figures.length;i++){
system.out.println(Figures+"area="+Figures.getarea( ));
}
}
}
public abstract class figure {
public abstract double getarea( );
}
public class rectangle extends (1) {
double height;
double width;
public rectangle (double height,double width){
this.height=height;
this.width=width;
}
public string tostring( ){
return"rectangle:height="+height+",width="+width+":";
}
public double getarea( ){
return (2)
}
}
public class square exends (3)
{
public square(double width
[填空题]阅读以下说明和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;


我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码