[计算机类试卷]国家二级C++机试(C++流)模拟试卷7及答案与解析.doc
《[计算机类试卷]国家二级C++机试(C++流)模拟试卷7及答案与解析.doc》由会员分享,可在线阅读,更多相关《[计算机类试卷]国家二级C++机试(C++流)模拟试卷7及答案与解析.doc(13页珍藏版)》请在麦多课文档分享上搜索。
1、国家二级 C+机试( C+流)模拟试卷 7及答案与解析 一、选择题 1 下列语句分别是不同程序中的第一个输入输出语句,若去掉其中的 “ left”,输出效果将发生变化的是 ( )。 ( A) cout left setfill(*) 357; ( B) cout left setw(5) 357; ( C) cout left setw(5) “ABCDE“; ( D) cout left “ABCDE“; 2 假定下列语句都是程序运行后首次执行的输出语句,其中输出结果与另外三 条语句不同的语句是 ( )。 ( A) cout setfill(*) 123 setw(9) 321; ( B)
2、cout setfill(*) setw(6) left 123 setw(6) right 321; ( C) cout 123 setfill(*) setw(6) 321; ( D) cout setfill(*) setw(9) left 123 321; 3 有如下程序: # inc1ude iostream #inc1ude iomanip using namespace std; int main() int s=123, 234; cout right setfill(*) setw(6); for(int l=0; 1 2; 1+) cout si end1; return
3、0: 运行时的输出结果是 ( )。 ( A) 123 234 ( B) *123 234 ( C) *123 *234 ( D) *123 234* 4 下列控制格式输入输出的操作符中,能够设置浮点数精度的是 ( )。 ( A) setprecision ( B) setw ( C) setfill ( D) showpoint 5 有如下程序: #inc1ude iostream #inc1ude iomanip using namespace std; int main() cout setw(10) setfill(x) setprecision(8) left; cout 12 345
4、6793 _ 98765; return 0; 若程序的输出是 12 345679x98765xxxxx,则划线处缺失的部分是 ( )。 ( A) setw(10) ( B) setfill(x) ( C) setprecision(8) ( D) right 6 下列语句都是程序运行时的第 1条输出语句,其中一条语句的输出效果与其他三条语句不同,该语句是 ( )。 ( A) cout internal 12345; ( B) cout left 12345; ( C) cout right 12345; ( D) cout setw(6) 12345; 7 有如下程序: #inc1ude i
5、omanip #inc1ude iostream using namespace std; int main() cout setfill(*) setw(6) 123 456; return 0; 运行时的输出结果是 ( )。 ( A) *123*456 ( B) *123456* ( C) *123456 ( D) 123456 8 下列控制对齐方式的操作符中,错误的是 ( )。 ( A) intemal ( B) center ( C) left ( D) right 9 有如下程序: #inc1ude iostream #inc1ude iomanip using namespace
6、std; int main() cout setfill(#) setw(4) “OKf 123 end1; return (); 运行这个程序的输出结果是 ( )。 ( A) #OK123 ( B) #OK#123 ( C) OK#123 ( D) OK#123# 10 若磁盘上已存在某个文本文件,其全路径文件名为 d:ncretest txt,下列语句中不能打开该文件的是 ( )。 ( A) ifstream file(“d:ncretest txt“); ( B) ifstream file(“d:ncretest txt“); ( C) ifstream file; file open
7、(“d:ncretest txt“); ifstream(“d:ncretest txt“); ( D) ifstream* pFile=new 11 语句 ofstreamf(“SALARYDAT“, ios base:app);的功能是建立流对象 f,并试图打开文件 SALARYDAT与 f关联,而且 ( )。 ( A)若文件存在,将其置为空文件;若文件不存在,打开失败 ( B)若文件 存在,将文件指针定位于文件尾;若文件不存在,建立一个新文件 ( C)若文件存在,将文件指针定位于文件首;若文件不存在,打开失败 ( D)若文件存在,打开失败;若文件不存在,建立一个新文件 12 如下函数的作
8、用是以双倍行距输出文件: void double_space(ifstream ( C) ifstream fin; fin open(“file dat“); ( D) ifstream *fin=new ifstream(); fin open(“file dat“); 16 当使用 ifstream流类定义一个流对象并打开一个磁盘文件时,文件的默认打开方式为 ( )。 ( A) ios_base:in ( B) ios_base:in lios_base:out ( C) ios_base:out ( D) ios_base:in fin open(“d:test txt“,ios_ba
9、se:in); ( B) fstream fio; fio open(“d:test txt“,ios_base:out); ( C) ofstream fout; fout open(“d:test txt“,ios_base:out); ( D) ofstream fout; fout open(“d:test txt“,ios_base:app); 21 如需要向一个二进制文件尾部添加数据,则该文件的打开方式为 ( )。 ( A) ios_base:app ( B) ios_base:binary|ios_base:out ( C) ios_base:out ( D) ios_base:
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 试卷 国家 二级 机试 模拟 答案 解析 DOC
