题目内容 (请给出正确答案)
[主观题]

阅读下列C++程序。阅读后请说明程序的功能,并对每条语句进行注释,说明其作用。 #include <iostream> using namespace std; int main() { int N; cin >> N; bool yes_no = true; for (int n = 2; n < N/2; n++) { if (N % n == 0) {

暂无答案
如搜索结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能会需要:
您的账号:
发送账号密码至手机
发送
更多“阅读下列C++程序。阅读后请说明程序的功能,并对每条语句进行…”相关的问题

第1题

阅读程序。阅读下列C++程序。阅读后请说明程序的功能,并对每条语句进行注释,说明其作用。 #include
<iostream> using namespace std; int fun(char str[ ]) { int n = 0, num = 0; while (str[n] != ‘\0’) { if (str[n] >= ‘A’ && str[n] <= ‘z’ || str[n]>= ‘a’ && str[n] <= ‘z’) num++; n++; } return num; int main( ) { cout fun( “123 abc abc” endl; 0;>

点击查看答案

第2题

阅读程序。阅读下列C++程序。阅读后请说明程序的功能,并对每条语句进行注释,说明其作用。添加注释并
提交源程序(请粘贴源代码或屏幕截图,不要上传附件)。 #include <iostream> using namespace std; int fun(char str[ ]) { int n = 0, num = 0; while (str[n] != ‘\0’) { if (str[n] >= ‘A’ && str[n] <= ‘z’ || str[n]>= ‘a’ && str[n] <= ‘z’) num++; n++; } return num; int main( ) { cout fun( “123 abc abc” endl; 0;>

点击查看答案

第3题

阅读下列C++程序。阅读后请说明程序的功能,并对每条语句进行注释,说明其作用。添加注释并提交源程序(请粘贴源代码或屏幕截图,不要上传附件)。 #include <iostream> using namespace std; #define PI 3.14 int main( ) { float r; cin >> r; float len; len = PI * 2
点击查看答案

第4题

阅读程序。阅读下列C++程序(共2个文件)。阅读后请说明程...

阅读程序。阅读下列C++程序(共2个文件)。阅读后请说明程序的功能,并对每条语句进行注释,说明其作用。添加注释并提交源程序(请粘贴源代码或屏幕截图,不要上传附件)。 // 程序文件:1.cpp #include <iostream> using namespace std; void fun(int x) { if (x < 0) { cout << ‘-‘; x = -x; } while (x != 0) { cout << x%10; x /= 10; } cout << endl; } void fun(char *str) { int N = 0; while (str[N] != ‘\0’) N++; for (int n = N-1; n >= 0; n--) cout << str[n]; cout << endl; } // 程序文件:2.cpp #include <iostream> using namespace std; extern void fun(int x); extern void fun(char *str); int main( ) { fun( -2015 ); fun( “-2015” ); return 0; }

点击查看答案

第5题

阅读下列C++程序。阅读后请说明程序的功能,并对每条语句进行注释,说明其作用。添加注释并提交源程
序(请粘贴源代码或屏幕截图,不要上传附件)。#include <iostream> using namespace std; int main( ) { int N; cin >> N; bool yes_no = true; for (int n = 2; n < N/2; n++) { if (N % n == 0) { yes_no = false; break; } } if (yes_no == true) cout << “Yes” << endl; else cout << “No” << endl; return 0; }

点击查看答案

第6题

阅读下列C++程序。阅读后请说明程序的功能,并对每条语句进行注释,说明其作用。添加注释并提交源程
序(请粘贴源代码或屏幕截图,不要上传附件)。#include <iostream> using namespace std; int main( ) { int N; cin >> N; bool yes_no = true; for (int n = 2; n <= n 2; n++) { if (n % 0) yes_no="false;" break; } (yes_no="=" true) cout “yes” endl; else “no” return 0;>

点击查看答案

第7题

阅读程序。阅读下列C++程序,对每条语句进行注释,说明其作用。 #include <iostream> using na
阅读程序。阅读下列C++程序,对每条语句进行注释,说明其作用。 #include <iostream> using namespace std; class CTest { private: int x, y; public: CTest(int p1 = 0, int p2 = 0) { x = p1; y = p2; } CTest(CTest &p) { x = p.x; y = p.y; } void Show( ) { cout << x << “, “ << y << endl; } }; int main( ) { CTest obj1; obj1.Show( ); CTest obj2(2, 5); obj2.Show( ); CTest obj3(obj2); obj3.Show( ); return 0; }

点击查看答案

第8题

阅读程序。阅读下列C++程序,对每条语句进行注释,说明其作用(请粘贴源代码或屏幕截图,不要上传附件
)。 #include <iostream> using namespace std; class CTest { private: int x, y; public: CTest(int p1 = 0, int p2 = 0) { x = p1; y = p2; } CTest(CTest &p) { x = p.x; y = p.y; } void Show( ) { cout << x << “, “ << y << endl; } }; int main( ) { CTest obj1; obj1.Show( ); CTest obj2(2, 5); obj2.Show( ); CTest obj3(obj2); obj3.Show( ); return 0; }

点击查看答案

第9题

下面叙述不正确的是()。

A、在程序中任意合适的地方都可以加上注释以便阅读

B、C语言中的每条执行语句都需要用分号结束

C、include命令所在行后面需要加分号

D、C语言具有高级语言的功能,也具有低级语言的一些功能

点击查看答案

第10题

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

【说明】

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

include<iostream.b>

include<math.h>

class Figure{

public:

virtual double getArea0=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; 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[i])->getarea()<<endl;

}

}

点击查看答案
热门考试 全部 >
相关试卷 全部 >
账号:
你好,尊敬的上学吧用户
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改
谢谢您的反馈

您认为本题答案有误,我们将认真、仔细核查,
如果您知道正确答案,欢迎您来纠错

警告:系统检测到您的账号存在安全风险

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

微信搜一搜
上学吧
点击打开微信
警告:系统检测到您的账号存在安全风险
抱歉,您的账号因涉嫌违反上学吧购买须知被冻结。您可在“上学吧”微信公众号中的“官网服务”-“账号解封申请”申请解封,或联系客服
微信搜一搜
上学吧
点击打开微信