砍伐城市树木,必须经城市人民政府()部门批准,并按规定补植或采取补救措施。
A.绿化行政主管
B.绿化规划
C.园林绿化
D.绿化管理
A.绿化行政主管
B.绿化规划
C.园林绿化
D.绿化管理
第1题
阅读下列程序说明和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
…
}
第2题
试题三(共 15 分)
阅读以下说明和 C 程序,将应填入 (n) 处的字句写在答题纸的对应栏内。
第3题
阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。
[说明]
本程序中预设了若干个用户名和口令。用户输入正确的用户名后,可以查找对应的口令,一旦输入结束标记“end”,程序结束。
[C++程序]
include <iostream. h>
include <string. h>
class User
{ protected:
char user[10];
char pass[7];
public:
User(char[ ],char[]);
(1) {return user;}
(2) {return pass;}
};
User::User(char u[],char p[])
{ strcpy(user,u);
strcpy(pass,p); }
void main()
{ User ua[]={User("Li","123456"),User("wang","654321"),User("Song","666666")
char name[10];
while(1)
cout< < "输入用户名:";
cin> >name;
if((3)= =0) break;
for(int i=0;i<3;i+ +)
if(strcmp(name,ua[i].getuser()) = =0){
cout< <"密码:" < < ua[i].getpass() < <endl;
(4);
if((5))cout< <"该用户不存在!" < <endl;
}
}
第4题
阅读以下说明和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;
}
}
第5题
() 阅读下列说明和C++代码,将应填入空(n)处的字句写在答题纸的对应栏内。【说明】 某中学开展中外中学生野外生存夏令营活动,由于中外学生的语言障碍,随队为外籍学员配置一名翻译。以下代码采用适配器(Adapter)模式模拟翻译适配器。其类图如下:
第6题
阅读以下说明和C++ 程序,将应填入(n)处的字句写在对应栏内。
[说明]
试从含有n个int 型数的数组中删去若干个成分,使剩下的全部成分构成一个不减的子序列。设计算法和编写程序求出数组的不减子序列的长。
[C++ 程序]
include<stdio.h>
define N 100
int b[]={9,8,5,4,3,2,7,6,8,7,5,3,4,5,9,1};
int a [N];
define n sizeofb/sizeofb[0]
void main ()
{
kit k,i,j;
(1)
(2)
for (i=1;i<n; i++ )
{
for (j=k;(3); j--);
(4); /*长为 j+1 的子序列的终元素存储在 a[j+1]*/
if ((5)k++; /*最长不减子序列长 k 增1*/
}
printf ("K = %d\n ",k );
}
第7题
阅读以下说明,以及用C++在开发过程中所编写的程序代码,将应填入(n)处的字句写在对应栏内。
【说明】
在下面函数横线处填上适当的字句,使其输出结果为:
构造函数.
构造函数.
1,2
5,6
析构函数
析构函数.
【C++代码】
include "iostream.h"
class AA
{ public;
AA(int i,int j)
{A=i; B=j;
cout<<"构造函数.\n";
}
~AA(){(1);}
void print();
private:
int A, B;
};
void AA∷print()
{cout<<A<<","<<B<<endl;}
void main()
{
AA *a1, *a2;
(2)=new AA(1, 2);
a2=new AA(5, 6);
(3);
a2->print();
(4) a1;
(5) a2;
}
第8题
阅读以下说明和C++代码,将应填入(n)处的字句写在对应栏内。
【说明】
C++标准模板库中提供了vector模板类,可作为动态数组使用,并可容纳任意数据类型,其所属的命名空间为std。vector模板类的部分方法说明如下表所示:
【C++代码】
include <iostream>
include <vector>
using namespace (1);
typedef vector< (2) > INTVECTOR;
const int ARRAY_SIZE = 6;
void ShowVector (INTVECTOR &theVector);
int main() {
INTVECTOR theVector;
// 初始化 theVector, 将theVector的元素依次设置为0至5
for (int cEachItem = 0; cEachItem < ARRAY_SIZE; cEachItem++}
theVector.push_back((3));
ShowVector(theVector); // 依次输出theVector中的元素
theVector.erase (theVector.begin () + 3};
ShowVector(theVector);
}
void ShowVector (INTVECTOR &theVector) {
if (theVector.empty ()) {
cout << "theVector is empty." << endl; return;
}
INTVECTOR::iterator (4);
for (theIterator=theVector.begin(); theIterator !=theVector.end(); theIterator++) {
cout << *theIterator;
if (theIterator != theVector.end()-1) cout << ", ";
}
cout << end1;
}
该程序运行后的输出结果为:
0,1,2,3,4,5
(5)
第9题
阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。
[说明]
下面程序输出一个矩形面积,以及矩形区域上的假想的作物产量。
[C++程序]
include <iostream.h>
class crop_assessment
{
int actual_crop;
int ideal_crop;
public:
void set(int in_actual,int in_ideal)
{
actual crop=in_actual;
ideal_crop=in_ideal;
}
int get_actual_crop(void){ (1) ;}
int get_ideal_crop(void){ (2) ;)
};
Class lot_size
{
int length;
int width;
(3) crop;
public:
void set(int 1,int w,int a,int i)
{
length=1;
width=w;
crop.set(a,i);
}
int get_area(void){return length*width;}
int get_data(void){return (4) ;}
int get_data2(void)freturn (5) ;}
}
int main()
{
Los_size small,medium;
small.set(5,5,5,25);
medium.set(10,10,10,50);
cout<<"For a small lot of area"<<smallget_area()<<“\n”;
cout<<"the actual crops are$"<<small.get_data2()<<"\n";
cout<<"and ideal crops are$”<<small.get_data()<<"\n";
cout<<"For a medium Lot of area"<<medium.get area()<<:\n”;
cout<<"the actual crops are$"<<medium.get_data2()<<"\n";
cout<<"and ideal crops are$"<<medium.get_data()<<"\n";
return 0;
}
第10题
阅读以下说明和C++抖程序,将应填入(n)处的字句写在答题纸的对应栏内。
【说明】
下面程序的功能是计算并输出某年某月的天数。
【C++程序】
include<iostream>
using namespace std;
(1) Month{Jan,Feb,Mar,Art,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%1001!=0)‖year%400==0);
};
int CaculateDays(){
switch((3) ){
case Feb:{
if((4) )return29;
e1Se return 28;
}
case Jan:case Mar:case May:case Jul:case AUg:case Oct:
case Dec:retllrn 31;
case Apr:case Jun:Case Sep:case Nov:roturu30;
}
};
private:
int year;
Month month;
};
void main(){
Date day(2000,Feb);
tout<<day. (5) ();
}
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!