搜题
网友您好,请在下方输入框内输入要搜索的题目:
搜题
题目内容 (请给出正确答案)
提问人:网友hyg1978 发布时间:2022-01-06
[主观题]

阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。【说明】 找一个最小的自然数,使它等于不

阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。

【说明】

找一个最小的自然数,使它等于不同的两组三个自然数的三次幂之和,即找最小的x,使得:x=a*a*a+b*b*b+c*C*c+d*d*d+e*e*e+f*f*f,其中,a、b、c、d、e、f者是是自然数,a≤b≤C≤d≤e≤f; [a,b,c]!=[d,e,f)

【C++程序】

include<stdio.h>

define N 100

void main ()

{

int i,j,il,ih,i0,j0,k0,il,j 1,k1;

int j1[N],jh[N];/*第i层平面的行的变化范围,自jl[i]至jh[i]*/

int k[N][N];/*第i层平面中,对应行j,当前的列号值为k[i][j]*/

int p[N], min;/*p[i]=i*i*i*/

i1=1;j1=1;k1=1;/*首先只局限下三角棱体的顶点*/

i1=1;ih=1;/*预置i的变化范围初值i1<=i<=ih*/

j1[1]=1;jh[1]=1;/*对应i层平面的行的变化范围*/

k[i1][j1[i1>=1;/*第i层平面中,对应行的列的初值*/

p[1]=1;

do

{

min=p[i1]+p[j1]+p[k1];

i0=i1;j0=j1;k0=k1;

if (i1==ih ) /*当前候选者在ih平面, 则ih增1*/

{

ih++;

(1);

/*为ih平面设定j的变化范围和对应k值*/

j1[ih]=1;jh[ih]=1;k[ih][1]=1;

}

if (i1==i1&&j 1==i1&&k1==i1 )

i1++;/*在i1平面最下角点找到候选者,i1增1*/

else

{

if (k1==1&&jh[i1]<i1 )

{/*在第一列找到候选者, i1平面的行的上界增1*/

(2);

k[i1][jh[i1>=1;

}

if(k1==j1&&j1[i1]<i1 )

else

(3);/*调整i1平面当前行的列号*/

}

i1=i1;/*预定最上平面的最小行的当前列为下一个候选者*/

j1=j1[i1];

k1=k[i1][j1];

for (i=i1;i<=ih;i++ ) /*寻找最小值所在平面号、行号和列号*/

{

for (j=j1[i];j<=jh[i];j++ )

if (p[i]+p[j]+p[k[i][j><(4))

{

i1=i;j 1=j;k1=k[i][j];

}

}

}while (p[i1]+p[j1]+p[k1]!=min&&(5));

if (p[i1]+p[j1]+p[k1]==min )

printf ("%4d=%2d^3+%d^3+%dA3=%2d^3+%d^3+%d^3\n",min,i0,j0,k0,i1,j1,k1 );

else printf ("The %d is too small.\n",N );

}

简答题官方参考答案 (由简答题聘请的专业题库老师提供的解答)
查看官方参考答案
更多“阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。【说明】 找一个最小的自然数,使它等于不”相关的问题
第1题
阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。[说明] 本程序中预设了若干个用户名和

阅读以下说明和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;

}

}

点击查看答案
第2题
阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。 [说明] 下面程序输出一个矩形面积,

阅读以下说明和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;

}

点击查看答案
第3题
阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。【说明】下面程序的功能是计算并输出某年

阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。

【说明】

下面程序的功能是计算并输出某年某月的天数,函数IsLeap Year()能够判断是否是闰年。

【C++程序】

include < iostream >

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) {

this→year = year;

if((2) ) month: Jan;

else month = m_ month;

};

~Date(){};

bool IsLeap Year() {

return ((year%4= =0 &&year% 100 ! =0)|| year%400= =0);

};

int CaculateDays() {

switch(m_month ) {

case (3) ;{

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 Sop: case Nov: return 30;

}

}

private:

int year;

Month month;

};

void main() {

Date day(2000,Feb);

cout < <day. (5) ();

}

点击查看答案
第4题
阅读以下说明和C++抖程序,将应填入(n)处的字句写在答题纸的对应栏内。【说明】 下面程序的功能是计

阅读以下说明和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) ();

}

点击查看答案
第5题
阅读以下说明和C++代码,将应填入____处的语句或语句成分写在答题纸的对应栏内。

某数据文件students.txt的内容为100名学生的学号和成绩,下面的程序将文件中的数据全部读入对象数组,按分数从高到低进行排序后选出排名前30%的学生。【C++代码】

阅读以下说明和C++代码,将应填入____处的语句或语句成分写在答题纸的对应栏内。	某数据文件stu

点击查看答案
第6题
●试题六 阅读以下说明和C++程序,将应填入(n)处的字句写在答题纸的对应栏内。 【说明】 设计一个

●试题六

阅读以下说明和C++程序,将应填入(n)处的字句写在答题纸的对应栏内。

【说明】

设计一个类模板Sample用于对一个有序数组采用二分法查找元素下标。

【C++程序】

#include<iostream.h>

#define Max 100∥最多元素个数

template<class T>

class Sample

{

T A[Max]:∥存放有序数序

int n:∥实际元素个数

public

Sample(){}∥默认构造函数

Sample(T a[],int i);∥初始化构造函数

int seek(T c);

void disp()

{

for(int i=0;i<n;i++)

cout<<A[i]<<"";

cout<<end1:

}

};

template<class T>

Sample<T>::Sample(T a[],int i)

{

n=i;

for(intj=0;j<i;j++)

(1) ;

}

template<class T>

int Sample<T>::seek(T c)

{

int low=0,high=n-1,mid;

while((2) )

{

mid=(low+high)/2;

if((3) )

return mid;

else if((4) )

low=mid+l;

else

(5) ;

}

return-1;

}

void main()

{

char a[]="acegkmpwxz";

Sample<char>s(a,1。);

cout<<"元素序列:";s.disp();

cout<<"元素′g′的下标:"<<s.seek(′g′)<<endl;

}

点击查看答案
第7题
阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。【说明】 设计一个类模板SamPle用于对一

阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。

【说明】

设计一个类模板SamPle用于对一个有序数组采用二分法查找元素下标。

【C++程序】

include < iostream. h >

define Max 100 //最多元素个数

template < class T >

class Sample

{

T A[Max]: //存放有序数序

int n: //实际元素个数

public

Sample() { } //默认构造函数

Sample(T a[] ,int i); //初始化构造函数

int seek(T c);

void disp()

{

for(int i=0;i <n;i ++)

cout<<A[i] <<" ";

cout<<endl:

} } template < class T >

Sample <T>: :Sample(T a[ ],int i)

{

n=i:

for(intj =0;j < i;j ++ )

(1);

}

template < class T >

int Sample < T >:: seek(T c)

{

int low =0,high = n-1 ,mid;

while((2))

{

mid = (low + high)/2;

if((3))

return mid;

else if((4) )

low=mid+|;

else

(5);

}

return-1;

}

void main()

{

char a[ ] ="acegkmpwxz";

Sample < char > s(a, 1);

cout<<"元素序列:" ;s. disp();

cout<<"元素'g'的下标:"<<s. seek('g') <<endl;

}

点击查看答案
第8题
阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内 [说明] 以下程序的功能是计算三角形、

阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内

[说明]

以下程序的功能是计算三角形、矩形和正方形的面积并输出。

程序由4个类组成:类Triangle,Rectangle和Square分别表示三角形、矩形和正方形;抽象类Figure提供了一个纯虚拟函数getArea(),作为计算上述三种图形面积的通用接口。

[C++程序]

include<iostream.h>

include<math.h>

class Figure{

public:

virtual double getArea()=0; //纯虚拟函数

};

class Rectangle: (1) {

protected:

double height;

double width;

public:

Rectangle(){};

Rectangle(double height,double width){

This->height=height;

This->width=width;

}

double getarea(){

return (2);

}

};

class Square: (3)

public:

square(double width){

(4);

}

};

class triangle: (5) {

double la;

double lb;

double lc;

public:

triangle(double la,double lb,double lc){

this->la=la;thiS->ib;this->lc;

}

double getArea(){

double s=(la+lb+lc)/2.0;

return sqrt(s*(s-la)**(s-lb)*(s-lc));

}

};

viod main(){

figure*figures[3]={

new triangle(2,3,3),new Rectangle(5,8),new Square(5)};

for(int i=0; i<3;i++){

cout<<"figures["<<i<<"]area="<<(figures)->getarea()<<endl;

}

}

};

点击查看答案
第9题
●试题六 阅读以下说明和C++程序,将应填入(n)处的语句写在答题纸的对应栏内。 【说明】 以下程序

●试题六

阅读以下说明和C++程序,将应填入(n)处的语句写在答题纸的对应栏内。

【说明】

以下程序的功能是计算三角形、矩形和正方形的面积并输出。

程序由4个类组成:类Triangle、Rectangle和Square分别表示三角形、矩形和正方形;抽象类Figure提供了一个纯虚拟函数getArea(),作为计算上述3种图形面积的通用接口

【C++程序】

#include<iostream.h>

#include<math.h>

class Figure{

public:

virtual double getArea()=0:∥纯虚拟函数

};

class Rectangle: (1) {

protected:

double height;

double width;

public:

Rectangle(){};

Rectangle(double height,double width){

this->height=height;

this->width=width;

}

double getArea(){

return (2) ;

}

};

class Square: (3) {

public:

Square(double width){

(4) ;

}

};

class Triangle: (5) {

double la;

double Ib;

double lc;

public:

Triangle(double la,double lb,double lc){

This->la=la;this->lb=lb;this->lc=lc;

}

double getArea(){

double s=(la+lb+±c)/2.0;

return sqrt(s*(s-1a)*(s-1b)*(s-1c));

}

};

void main(){

Figure*figures[3]={

new Triangle(2,3,3),new Rectangle(5,8),new SqUare (5) );

for (int i=0;i<3;i++){

cout<<"figures["<<i<<"]area="<<(figures[i])->getArea()<<endl;

}

}

点击查看答案
第10题
阅读以下说明C++代码,将应填入(n)处的字句写在对应栏内。[说明] 以下程序的功能是实现堆栈的一些

阅读以下说明C++代码,将应填入(n)处的字句写在对应栏内。

[说明]

以下程序的功能是实现堆栈的一些基本操作。堆栈类stack共有三个成员函数:empty判断堆栈是否为空;push进行人栈操作;pop进行出栈操作。

[C++程序]

include "stdafx. h"

include <iostream, h>

eonst int maxsize = 6;

class stack {

float data[ maxsize];

int top;

public:

stuck(void);

~ stack(void);

bool empty(void);

void push(float a);

float pop(void);

};

stack: :stack(void)

{ top =0;

cout < < "stack initialized." < < endl;

}

stack:: ~stack(void) {

cout < <" stack destoryed." < < endl;

bool stack:: empty (void) {

return (1);

void stack: :push(float a)

if(top= =maxsize) {

cout < < "Stack is full!" < < endl;

return;

data[top] =a;

(2);

}

float stack:: pop (void)

{ if((3)){

cout< < "Stack is undcrflow !" < < endl;

return 0;

(4);

return (5);

}

void main()

{ stack s;

coat < < "now push the data:";

for(inti=l;i< =maxsize;i+ +) {

cout< <i< <" ";

s. push(i);

}

coat < < endl;

cout< < "now pop the data:";

for(i = 1 ;i < = maxsize ;i + + )

cout< <s. pop()< <" ";

}

点击查看答案
第11题
阅读以下说明和C++程序,将应填入(n)处的字句写在答题纸的对应栏内。说明 以下程序的功能是计算三

阅读以下说明和C++程序,将应填入(n)处的字句写在答题纸的对应栏内。

说明

以下程序的功能是计算三角形、矩形和正方形的面积并输出。

程序由4个类组成:类Triangle、Rectangle和Square分别表示三角形、矩形和正方形;抽象类Figure提供了一个纯虚拟函数getArea(),作为计算上述三种图形面积的通用接口。

c++程序

include <iostream.h>

inclule <math.h>

class Figure {

public:

virtual double getArea()= 0; // 纯虚拟函数

};

class Rectangle: (1) {

protected:

double height;

double width;

public:

Rectangle() { };

Rectangle(double height, double width) {

this->height = height;

this->width = width;

}

double getArea() {

return (2) ;

}

class Square: (3) {

public:

Square(double width) {

(4) ;

}

};

class Triangle: (5) {

double la;

double lb;

double lc;

public:

Triangle(double la, double lb, double lc) {

this->la = la; this->lb ='lb; this->lc = lc;

}

double getArea() {

double s = (la+lb+lc)/2.0;

return sqrt(s*(s-la)*(s-lb)*(s-lc));

} }; void main() {

Figure* figures[3] = {

new Triangle(2,3,3), new Rectangle(5,8), new Square(5)};

for (int i = 0; i < 3; i++) {

com << "figures[" << i << "] area =" << (figures[i])->getArea0 << endl;

}

点击查看答案
重要提示: 请勿将账号共享给其他人使用,违者账号将被封禁!
查看《购买须知》>>>
重置密码
账号:
旧密码:
新密码:
确认密码:
确认修改
购买搜题卡查看答案
购买前请仔细阅读《购买须知》
请选择支付方式
微信支付
支付宝支付
点击支付即表示你同意并接受《服务协议》《购买须知》
立即支付
搜题卡使用说明

1. 搜题次数扣减规则:

功能 扣减规则
基础费
(查看答案)
加收费
(AI功能)
文字搜题、查看答案 1/每题 0/每次
语音搜题、查看答案 1/每题 2/每次
单题拍照识别、查看答案 1/每题 2/每次
整页拍照识别、查看答案 1/每题 5/每次

备注:网站、APP、小程序均支持文字搜题、查看答案;语音搜题、单题拍照识别、整页拍照识别仅APP、小程序支持。

2. 使用语音搜索、拍照搜索等AI功能需安装APP(或打开微信小程序)。

3. 搜题卡过期将作废,不支持退款,请在有效期内使用完毕。

请使用微信扫码支付(元)

订单号:

遇到问题请联系在线客服

请不要关闭本页面,支付完成后请点击【支付完成】按钮
遇到问题请联系在线客服
恭喜您,购买搜题卡成功 系统为您生成的账号密码如下:
重要提示:请勿将账号共享给其他人使用,违者账号将被封禁。
发送账号到微信 保存账号查看答案
怕账号密码记不住?建议关注微信公众号绑定微信,开通微信扫码登录功能
警告:系统检测到您的账号存在安全风险

为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!

- 微信扫码关注简答题 -
警告:系统检测到您的账号存在安全风险
抱歉,您的账号因涉嫌违反简答题购买须知被冻结。您可在“简答题”微信公众号中的“官网服务”-“账号解封申请”申请解封,或联系客服
- 微信扫码关注简答题 -
请用微信扫码测试
欢迎分享答案

为鼓励登录用户提交答案,简答题每个月将会抽取一批参与作答的用户给予奖励,具体奖励活动请关注官方微信公众号:简答题

简答题官方微信公众号

简答题
下载APP
关注公众号
TOP