首页 > 计算机等级考试
题目内容 (请给出正确答案)
[主观题]

阅读以下程序 #include<fstream.h> void main() { ifstream infile; ofstream outfile; fstream

阅读以下程序

#include<fstream.h>

void main()

{

ifstream infile;

ofstream outfile;

fstream iofile;

iofile.open("a.txt",ios::in);

iofile.close();

iofile.open("b.txt",ios::out);

}

下列描述错误的是

A.对象infile只能用于文件输入操作

B.对象outfile只能用于文件输出操作

C.对象iofile在文件关闭后,不能再打开另一个文件

D.对象iofile可以打开一个文件同时进行输入和输出

查看答案
答案
收藏
如果结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能还需要:
您的账号:
发送账号密码至手机
发送
安装优题宝APP,拍照搜题省时又省心!
更多“阅读以下程序 #include<fstream.h> voi…”相关的问题
第1题
阅读以下程序#include<iostream.h>void main(){charline[10];in>>line;cout<<line<<endl;}如运行

阅读以下程序 #include<iostream.h> void main() { charline[10]; in>>line; cout<<line<<endl; } 如运行时输入This is an example.<CR>,则程序的输出结果是()。

A.This

B.This is

C.This is a

D.This is an example.

点击查看答案
第2题
阅读以下程序 #include(iostream.h>voidmain() {charline[10]; cin>>line; cout<&

阅读以下程序

#include(iostream.h>

voidmain()

{

charline[10];

cin>>line;

cout<<1ine<<endl;

}

如运行时输入“Thisisanexample.<CR>”,则程序的输出结果是()。

A.This

B.Thisis

C.Thisisa

D.Thisisanexample

点击查看答案
第3题
阅读以下程序 #include(iostream.h> voidmain() { charline[10]; cin>>line; cou

阅读以下程序 #include(iostream.h> voidmain() { charline[10]; cin>>line; cout<<1ine<<endl; } 如运行时输入“Thisisanexample.<CR>”,则程序的输出结果是()。

A.This

B.Thisis

C.Thisisa

D.Thisisanexample

点击查看答案
第4题
请阅读以下程序:#include<stdio.h>#include<string.h>void fun(int b[]){static int i=0;do{b[i]

请阅读以下程序: #include<stdio.h> #include<string.h> void fun(int b[]) { static int i=0; do {b[i]+=b[i+1]; }while(i<2);} main() { int k,a[5]={1,3,5,4,9}; fun(A); for(k=0;k<5;k++)printf("%d",a[k]);} 上面程序的输出是()。

A.13579

B.48579

C.48549

D.48999

点击查看答案
第5题
阅读以下程序: include<iostream.h> void main() { static int a[][3]={9,7,5,3,1,2,4,6,8}; int

阅读以下程序:

include<iostream.h>

void main()

{

static int a[][3]={9,7,5,3,1,2,4,6,8};

int i,j,s1=0,s2=0;

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

for(j=0;j<3;j++)

{

if(i==j)s1=sl+a[i][j];

if(i+j==2)s2=s2+a[i][j];

}

cout<<s1<<","<<s2<<endl;

}

则该程序的输出结果为【 】。

点击查看答案
第6题
阅读以下程序#include<stdio.h>main(){Int Case;float printF;printf("请输入2个数:");scanf("%d

阅读以下程序 #include<stdio.h> main() {Int Case;float printF; printf("请输入2个数:"); scanf("%d %f",&Case,&printF); printf("%d%f\n",Case,printF); } 以下说法正确的是()。

A.定义浯句出错,Case是关键字,不能用作用户自定义标识符,printF不能用作用户自定义标识符

B.定义语句出错,Int无法被识别

C.定义语句无错,scanf不能作为输入函数使用

D.定义语句无错,printf不能输出Case的值

点击查看答案
第7题
阅读以下程序及对程序功能的描述,其中正确的是 #include <stdio.h> main() {FILE *in,*out

阅读以下程序及对程序功能的描述,其中正确的是

#include <stdio.h>

main()

{ FILE *in,*out;

char ch,infile[10],outfile[10];

printf("Enter the infile name:\n");

scanf("%s",infile);

printf("Enter the outfile name: \n");

scanf("%s",outfile);

if((in=fopen(infile,"r"))==NULL)

{ printf("cannot open infile\n");

exit(0); }

if((out=fopen(outfile,"w"))==NULL)

{ printf("cannot open outfile\n");

exit(0); }

while(! feof(in))fputc(fgetc(in),out);

fclose(in);fclose(out); }

A.程序完成将磁盘文件的信息在屏幕上显示的功能

B.程序完成将两个磁盘文件合二为一的功能

C.程序完成将一个磁盘文件复制到另一个磁盘文件中

D.程序完成将两个磁盘文件合并并在屏幕上输出

点击查看答案
第8题
阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。 [说明] 下面程序实现十进制向其它进

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

}

}

点击查看答案
第9题
阅读以下程序及对程序功能的描述,其中正确的描述是#include<stdio.h>main(){ FILE*in,*out;char

阅读以下程序及对程序功能的描述,其中正确的描述是 #include<stdio.h> main() { FILE*in,*out; char ch,infile[10],outfile[10]; printf("Enter the infile name:\n"); scanf("%s",infile); printf("Enter the outfile name:\n"); scanf("%s",outfile); if((in=fopen(infile,"r"))==NULL) { printf("cannot open infile\n"); exit(0);} if((out=fopen(outfile,"w"))==NULL) { printf("cannot open outfile\n"); exit(0);} while(!feof(in))fputc(fgetc(in),out); fclose(in); fclose(out);}

A.程序完成将磁盘文件的信息在屏幕上显示的功能

B.程序完成将两个磁盘文件合二为一的功能

C.程序完成将一个磁盘文件复制到另一个磁盘文件中

D.程序完成将两个磁盘文件合并并在屏幕上输出

点击查看答案
第10题
阅读以下说明和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;

}

}

点击查看答案
退出 登录/注册
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改