题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2024-01-30 00:39:01

[填空题]下面程序是一个堆栈的类模板,在横线处填上适当语句,完成类模板的定义。
#define MAXSIZE 100
template <class T>
class Stack

T s[MAXSIZE];
int top;
public:
stack( )

top=1;

void push(T newValue)

if(top<MAXSIZE)

top=top+1;
s[top]=newValue;

else
cout<<"堆栈满,无法进栈"<<end1;

void pop( );
;
【12】

if(top>1)

cout<<s[top]<<end1;
top=top-1;

else
cout<<"堆栈空! "<<end1;

更多"下面程序是一个堆栈的类模板,在横线处填上适当语句,完成类模板的定义。 "的相关试题:

[填空题]下面程序是一个堆栈的类模板,在横线处填上适当语句,完成类模板的定义。
#define MAXSIZE 100
template <class T>
class Stack

T s[MAXSIZE];
int top;
public:
stack( )

top=1;

void push(T newValue)

if(top<MAXSIZE)

top=top+1;
s[top]=newValue;

else
cout<<"堆栈满,无法进栈"<<end1;

void pop( );
;
【12】

if(top>1)

cout<<s[top]<<end1;
top=top-1;

else
cout<<"堆栈空! "<<end1;

[填空题]下面程序是一个堆栈的类模板,在横线处填上适当语句,完成类模板的定义。 #define MAXSIZE 100 template <class T> class Stack { T s[MAXSIZE]; int top; public: stack( ) { top=1; } void push(T newValue) { if(top<MAXSIZE) { top=top+1; s[top]=newValue; } else cout<<"堆栈满,无法进栈"<<end1; } void pop( ); }; 【12】 { if(top>1) { cout<<s[top]<<end1; top=top-1; } else cout<<"堆栈空! "<<end1; }
[简答题]下面程序是关于类的继承的用法。阅读下面程序,根据程序中的注释在每一条横线处填写一个语句,使程序的功能完整,且运行程序后的输出结果为:
I am parentclass!
I am childclass!
I am childclass!
注意:请勿改动main( )主方法和其他已有的语句内容,仅在下划线处填入适当的语句。
class Parent
void printMe( )
System. out. println( "I am parentclass ! ");


class Child extends Parent
void printMe( )
System. out. println( "I am childclass! ")

void printAll( )
______. printMe( ); //调用父类的方法
______. printMe( ); //调用本类的方法
printMe ( );


public class TestJieCheng
public static void main(String args[])
______
myC. printAll( );


[简答题]请在下面程序中的每条横线处填写一个语句,使程序的功能完整。程序的输出结果为: TIME=1867 b=9 i=123 注意:请勿改动main( )主方法和其他已有的语句内容,仅在横线处填入适当的语句。 import java.io.*; public class DataType{ public______________void main(String args[]) { byte b; int i;//定义变量i为int类型 ___________________________ //定义常量TIME为整型,且值为1867 i=123;//给变量i赋值,该值为十进制的123 __________________________________//给变量赋值,改值为,八进制的11,十进制的9 System.out.println("TIME”+TIME); System.out.println("b="+b); System.out.println("i="+i); } }
[简答题]请在下面程序中的每条横线处填写一个语句,使程序的功能完整。程序的输出结果为:
TIME=1867
b=9
i=123
注意:请勿改动main( )主方法和其他已有的语句内容,仅在横线处填入适当的语句。
源程序文件代码清单如下:
import java.io.*;
public class DataType

public ______ void main(String args[])

byte b;
int i;//定义变量i为int类型
______//定义常量TIME为整型,且值为1867
i=123;//给变量i赋值,该值为十进制的123
______//给变量赋值,改值为八进制的11,十进制的9
System.out.println("TIME"+TIME);
System.out.println("b="+b);
System.out.println("i="+i);


[简答题]下面程序执行后,输出结果为:true请在程序的每条横线处填写一个语句,使程序的功能完整。 注意:请勿改动main( )主方法和其他已有的语句内容,仅在横线处填入适当的语句。 public class TestStringCompare{ {public static void main(String ____________________ args) {char charl[]={’t’,’e’,’s’,’t’}; char char2[]={’t’,’e’,’s’,’t’,’1’}; String str1=new String(___________________); String str2=new String(char2,0,4); System.out.println(__________________________); } }
[填空题]下面的程序用“冒泡”法将数组a中的10个整数按升序排列,请在横线处将程序补充完整。
public class Sun
public static void main(String args[])
int[]a=678,45,324,528,439,387,87,875,273,823;
int a1=0;
for(int i=0; i<=8;i++)
for(int j=______;j<=9;i++)
if(a[i]>=a[j])
al=a[j];
a[j]=a[i];
a[i]=al;


for(int i=0;i<=9;i++)
System.out.println(a[i]);


[简答题]下面程序的功能是输出字符串“HGPEDCBA”, 请在程序的每条横线处填写一个适当的语句,使程序的功能完整。 注意:请勿改动main( )主方法和其他已有的语句内容,仅在横线处填入适当的语句。 import java.io.*; public class InputString{ public static void main(String args[ ]){ String stringname= new _______________ ("ABCDEFGH"); for(int i= _______________ i>=0;i--) System.out.println(String.valueOf(stringname.________________)); } }
[填空题]下面的程序用“冒泡”法将数组a中的10个整数按升序排列,请在横线处将程序补充完整。
public class Sun
public static void main(String args[])
int[] a=678,45,324,528,439,387,87,875,273,823 ;
int a1=0;
for(int i=0; i<=8;i++)
for(int j= 【12】 ;j<=9;j++)
if(a[i]>=a[j])
a1=a[j];
a[j]=a[i];
a[i]=a1;


for(int i=0;i<=9;i++)
System. out. println(a[i]);


[简答题]下面程序是关于位运算符的使用。请在程序的每条横线处填写一个位运算符,使程序的功能完整。 注意:请勿改动main( )主方法和其他已有的语句内容,仅在横线处填人适当的位运算符。 public class BitOperator{ public static void main(String args[]){ int a=9; //二进制数1001 int b=15;//二进制数1111 int c=8; //二进制数1000 int d,e,f,g,h; d=a__________b;//二进制数1001,也就是十进制数9 e=a|b;//二进制数1111,也就是十进制数15 f=a__________b;//二进制数0110,也就是十进制数6 g=a<<2;//9×4=36 h=c__________1;//8/2=4 System.out.println("d="+d); System.out.println("e="+e); System.out.println("f="+f); System.out.println("g="+g); System.out.println("h="+h); } }
[简答题]下面的程序是用do_while语句计算10的阶乘。请在程序的每条横线处填写一个语句,使程序的功能完整。 注意:请勿改动main( )主方法和其他已有的语句内容,仅在横线处填入适当的语句。 源程序文件代码清单如下: public class DoWhileLoop { public static void main(________) { int n=10; long result=1; do { _______________ } ______________ System.out.println("10的阶乘为: "+result); } }

我来回答:

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

订单号:

截图扫码使用小程序[完全免费查看答案]
请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码