更多"下列程序用于将源文件中的字母进行大小写转换,请填写while语句。 "的相关试题:
[填空题]下列程序用于将源文件中的字母进行大小写转换,请填写while的请句。
#include<iostream.h>
#include<fstream.h>
#include<iomanip.h>
void main( )
char ch;
fstream file1,file2;
char fnl[10],fn2[10];
cout<<“输入源文件名:”;
cin>>fn1;
cout<<“输入目标文件名:”;
cin>>fn2;
ilel.open(fn1,ios::in);
while( )
证(ch)=,a,&&ch<=’z,)
ch=ch-/a/+’A’;
file2.put(ch);
file1.close( );
file2.close( );
[填空题]下列程序用于将源文件中的字母进行大小写转换,while的条件是 【14】 。
#include<iostream. h>
#include<fstream. h>
#include<iomanip. h>
void main( )
char ch;
fstream filel, file2
char fn1[10], fn2[10];
cout<<"输入源文件名:";
cin>>fn1
cout<<"输入目标文件名:";
tin>>fn2
file1, open(fn1 ,ios: :in);
file2, open(fn2, ios:: out);
while(________)
if(ch>=’a’&&ch<=’z’)
ch=ch-’a’+’A’,
file2, put(ch),
file1, close( ),
file2, close( );
[填空题]下列程序用于将源文件中的字母进行大小写转换,while的条件是 【14】 。
#include<iostream. h>
#include<fstream. h>
#include<iomanip. h>
void main( )
}
char ch;
fstream filel, file2
char fn1[10], fn2[10];
cout<<"输入源文件名:";
cin>>fn1
cout<<"输入目标文件名:";
tin>>fn2
file1, open(fn1 ,ios: :in);
file2, open(fn2, ios:: out);
while(________)
{
if(ch>=’a’&&ch<=’z’)
ch=ch-’a’+’A’,
file2, put(ch),
}
file1, close( ),
file2, close( );
}
[填空题]下列程序用于将源文件中的字母进行大小写转换,while的条件是______。
#include<iostream.h>
#include<fstream.h>
#include<iomanip.h>
void main( )
char ch;
fstream filel,file2;
char fnl[10],fn2[10];
cout<<"输入源文件名:";
cin>>fn1;
cout<<"输入目标文件名:";
cin>>fn2;
filel.open(fnl,ios::in);
file2.open(fn2,ios::out);
while(______)
if(ch>=’a’&&ch<=’z’)
ch=ch=’a’+’A’;
file2.put(ch);
filel.close( );
file2.close( );
[填空题][说明]
下而程序实现十进制向其他进制的转换。
[C++程序]
#include"ioStream.h"
#include"math.h"
#include <conio.h>
typedef struct node
int data;
node *next;
Node;
class Transform
public:
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) j
(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;
[填空题]在下面程序的横线处填上适当的内容,使程序执行后的输出结果为ABCD。
#include <iostream>
using namespace std;
class A
public: A( ) cout<<’A’;
;
class B: 【14】
public: B( )cout<<’B’;
class C: virtual public A
public: C( )cout<<’C’;
class D:public B, public C
public: D( ) cout<<’D’;
;
void main( ) D obj;
[填空题]在下面的程序的横线处填上适当的语句,使该程序的输出结果为12。
#include<iostream>
using namespace std;
class TestClass
public:
int a,b;
TestClass(int i,int j)
a=i;
b=j;
;
class TestClass1:public TestClass
int a;
public:
TestClass1(int x):TestClass(x,x+1)
void show( )
______;∥输出基类数据成员a的值
cout<<b<<endl;
;
int main( )
TestClass1 d(1);
d.show( );
return 0;
[填空题]以下程序设计功能是:将结构体变量time 中的内容写到文件中。
#include <iostream>
using namespace std;
struct date
int year;
int month;
int day;
int main ( )
date time = 2005, 1, 1 ;
ofstream outdate;
outdate.open( "d://date.txt", ios :: binary );
outdate.write(____________, sizeof( tt ) );
outdate.close( );
return 0;
则程序中空白处应该填入的语句为 【15】 。
[填空题]已知下列程序的输出结果是42,请将横线处缺失的部分补充完整。
#include<iostream>
using namespace std;
class Foo{
int value;
public:
Foo( ):value(0){}
void setValue(int value)
{______=value; ∥给Foo的数据成员value赋值}
void print( ){cout<<value;p}
};
int main( )
{
Foo f;
gf.setValue(42);
f.print( );
return 0;
}
[填空题]下列程序中需要清理动态分配的数组,划线处应有的语句是 【13】 。
#include<iostream, h>
class person
{
int age, tall;
public:
person( ) { age= 0; tall= 40; cout<<"A baby is born. "<<end1;}
person(int i) {age=i, tall=40, cout<<"A old person. "<<end1;}
person(int i, int i) { age = i; tall = j; cout <<" a old person with tall. "<<
end1;}
~person( ) {cout<<" person dead. "<<end 1;}
void show( )
{
cout<<"age= "<<age<<" ,tall= "<<tall<<end1;
}
};
void main( )
{
person * ptr;
ptr = new person[3];
ptr[0]=person ( )
ptr[1]=person(18);
ptr[2]=person(20,120);
for(int i=0;i<3; i++)
ptr[i]. show( );
______
}
[填空题]已知下列程序的输出结果是42,请将下画线处缺失的部分补充完整。
#include <iostream>
using namespace std;
class Foo
int value;
public:
Foo( ):value(0)
void setValue(int value)
______=value;//给Foo的数据成员value赋值
void print( )eout<<value;
;
int main( )
Foo f;
f.setValue(42);
f.print( );
return 0;
[填空题]Java是区分大小写的。源文件名与程序类名必须相同,其扩展名为 ______,源文件中最多只能有一个 ______ 类,其他类的个数不限。
[填空题]下列程序编译错误,是由于划线处缺少某个语句,该语句是______。
#include<iostream.h>
class A
private:
int numl;
public:
A( ):numl(0)
A(int i):numl(i)
;
class B
private:
int num2;
public:
B( ):num2(0)
B(int i):num2(i)
int my_math(A obj1, B obj2);
;
int B::my_math(A obj1,B obj2)
return(obj1.numl+obj2.num2);
void main(void)
A objl(4);
B obj,obj2(5);
cout<<"obj1+obj2:"<<obj.my_math(obj1,obj2);
[填空题]设文件temp.txt 已存在,则以下的打印结果是 【15】
#include <iostream>
#include <fstream>
using namespace std;
int main( )
{
ofstream outf ("temp.txt",ios base: :trunC) ;
outf<<"How you doing";
outf.close( );
ifstream inf("temp.txt");
char str[20];
inf>>str;
inf.close( );
cout<<str;
return 0;
}
[填空题]下列类的构造函数不能通过编译,正确的构造函数应该是______。
#include<iostream.h>
class Sample
{
public:
int n;
const int con;
Sample(int m) {con=m+1;n=m;}
void disp( ) {cout<<"normal:n="<<n<<endl;}
void disp( )const {cout<<"static:n="<<n<<endl;}
};
void main( )
{
const Sample a (12);
Sample b (13);
a.disp( );
b.isp( );
cout<<a.n<<","<<b.con<<endl;
}