题目详情
当前位置:首页 > 计算机考试 > 初级程序员
题目详情:
发布时间:2023-12-11 22:04:55

[填空题][说明]
下而程序实现十进制向其他进制的转换。
[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;


更多"[说明] 下而程序实现十进制向其他进制的转换。 [C++程序] "的相关试题:

[填空题][说明]
下面程序实现十进制向其他进制的转换。
[Java程序]
C1ass Node
int data;
Node next;

class Transform
private Node top;
publiC void print( )
Node P;
while(top !=null)
P=top;
if(P.data>9)
System.out.print((char)(p.data+55));
else
System.out.print(p.data);
top=P.next;


public void Trans(int d,int i)(//d为数字;i为进制
int m;
(1) n=false;
Node P;
while(d>0)
(2) ;
d=d/i;
P=flew Node( );
if( (3) )
P.data=m;
(4) ;
top=P;
n=true;

else
p.data=m;
(5)
toP=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; }
[填空题]下列程序用于将源文件中的字母进行大小写转换,请填写while语句。
#include<iostream.h>
#include<fstream.h>
#include<iomanip.h>
void main( )

char ch;
fstream file1,file2;
char fn1[10],fn2[10];
cout<<"输入源文件名:";
cin>>fn1;
cout<<"输入目标文件名:";
cin>>fn2;
file1.open(fn1,ios::in);
while(______)

if(ch>=’a’&&ch<=’z’)
ch=ch=’a’+’A’;
file2.put(ch);

file1.close( );
file2.close( );

[填空题]下列程序的输出结果为012,请根据注释将横线处的缺失部分补充完整。
#include<iostream>
using namespace std;
class Test
public:
Test(int A) data=a;
~Test( )
void print( )cout<<data;)
private:
int data;
;
int main( )
Test t[3]=______;//对有3个元素的Test类对象数组t初始化
for(int i=0; i<3; i++) t[i]. 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;

[填空题]下列程序编译错误,是由于划线处缺少某个语句,该语句是______。
#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; }
[单项选择]下面是用来实现十六进制数0CH转换对应的ASCII码的8086/8088程序,选择正确的指令填在第4条指令位置上。
1 TBARA DB 30H,31H,32H,33H,34,35H,36H,37H
DB 38H,39H,41H,42H,43H,44H,45H,46H
2 MOV BX,OFFSET TABBA
3 MOV AL,0CH
4 ( )
A. ADD AL,30H
B. XOR AL,FFH
C. ADD AL,40H
D. XLAT TABBA
[简答题]

请编制程序ReadDat( )实现从文件in.dat中读取100个十六进制数到字符串数组xx中;再编制函数h16to10( ),将xx中的十六进制数转换成十进制数并把已转换的十进制数仍存放在字符串数组xx,最后调用函数WriteDat( )把结果输出到out.dat文件巾。原始数据文件存放的格式是:每行存放10个数,并用逗号隔开(每个数均大于0且小于等于2000)。
请勿改动主函数main( )、输出数据函数writeDAT( )的内容。
[试题源程序]
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#define MAX 10
char xx[MAX][20];
void WriteDat(void);
int ReadDat(void)
{
FILE*fp;
if((fp=fopen("IN.DAT,"r"))==NULL)return 1:
fclose(fp);
return 0;
}
void H16tol0(void)
{
void main( )
{
int i;
for(i=0;i<MAX;i++)memset(xx,0,20);
if(ReadDat( ))
{
printf("Can’t open the data file in.dat!\007\n");
return;
}
H16to10( );
WriteDat( );
{
void WriteDat(void)
{
FILE*fp;
int i;
fp=fopem("OUT DAT","w");
for(i=0;i<MAX;i++)fprintf(fp,&

[填空题]C语言源程序中用十六进制表示整型常数必须以___(1)___开头。
[单项选择]实现输出为八进制的符号是( )。
A. dec
B. hex
C. oct
D. setw(8)
[简答题]
阅读下列程序说明和C++程序,把应填入其中(n)处的字句,写对应栏内。
【说明】
下面的程序实现了类String的构造函数、析构函数和赋值函数。
已知类String的原型为:
class String
{
public:
String(coust char * str = NULL); //普通构造函数
String( const String &other); //拷贝构造函数
~String(void); //析构函数
String & operate =(const String &other); //赋值函数
private:
char * m_data; // 用于保存字符串
};
//String 的析构函数
String:: ~String (void)
{
(1) ;
}
//String 的普通构造函数
String: :String( const char * str)
{
if (2)
{
m_data = new char[1];
*m_data = ’/0’;
}
else
{
int length = strlen(str);
m_data = new ehar[ length + 1 ];
strepy(m_data, str);
}
}
//拷贝的构造函数
String:: String( const String &other)
{ int length = strlen(other. m_data);
m_data = new char[ length + 1 ];
strepy(m_data, other, m_data); //赋值函数
String & String::operate = (eonst Stri

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码