题目详情
当前位置:首页 > 计算机考试 > 初级程序员
题目详情:
发布时间:2024-03-10 06:17:19

[多项选择]【说明】
以下【C++程序】用于实现两个多项式的乘积运算。多项式的每一项由类Item描述,而多项式由类List描述。类List的成员函数主要有:
createList( ):创建按指数降序链接的多项式链表,以表示多项式:
reverseList( ):将多项式链表的表元链接顺序颠倒:
multiplyList(ListL1,ListL2)计算多项式L1和多项式L2的乘积多项式。
【C++程序】
#include <iostream.h>
class List;
class Item
friend class List;
private:
double quot ;
int exp ;
Item *next;
Public:
Item(double_quot,int_exp)
(1) ;
;
class List
private:
Item *list;
Public:
List( )
list=NULL:

void reverseList( );
void multiplyList(List L1,List L2);
void createList( );
;
void List::createList( )
Item *p,*U,*pre;
int exp;
double quot;
list = NULL;
while (1)
cout << "输入多项式中的一项(系数、指数) :" << endl;
cin >> quot >> exp:
if ( exp<0 )
break ; //指数小于零,结束输入
if ( quot=0 )
continue;
p = list;
while ( (2) ) //查找插入点

更多"【说明】 以下【C++程序】用于实现两个多项式的乘积运算。多项式的每"的相关试题:

[简答题]【程序6说明】
本程序实现两个多项式的乘积运算。多项式的每一项由类Item描述,而多项式由类List描述。类List的成员函数有:
createList( ):创建按指数降序链接的多项式链表,以表示多项式。
reverseList( ):将多项式链表的表元链接顺序颠倒。
multiplyList(List L1,List L2):计算多项式L1和多项式L2的乘积多项式。
【程序6】
#include<iostream.h>
class List;
class |tem
friend class List;
private:
double quot;
int exp;
|tem * next;
public:
|tem(double_quot,int_exp)
(1)

class List
private:
|tem * list;
public:
List( )list=NULL;
void reverseList( );
void multiplyList(List L1,List L2);
void createList( );

void List::createList( )
|tem * p,* u,*pre;
int exp;
doubte quot;
list=NULL;
while(1)
cout<<"输入多项式中的一项(系数、指数):"<<endl;
cin>>quot>>exp:
if(exp<0)break; //指数小于零,结束输入
if(quot==0)continue;
p=list;
while( (2) ) //查找插入点
pre=p;p=p->next;
if(p!=NULL&&exp==p->exp) p->quot+=quo
[简答题]【程序6说明】 本程序实现两个多项式的乘积运算。多项式的每一项由类Item描述,而多项式由类List描述。类List的成员函数有: createList( ):创建按指数降序链接的多项式链表,以表示多项式。 reverseList( ):将多项式链表的表元链接顺序颠倒。 multiplyList(List L1,List L2):计算多项式L1和多项式L2的乘积多项式。 【程序6】 #include<iostream.h> class List; class |tem{ friend class List; private: double quot; int exp; |tem * next; public: |tem(double_quot,int_exp) { (1) ;} }; class List { private: |tem * list; public: List( ){list=NULL;} void reverseList( ); void multiplyList(List L1,List L2); void createList( ); }; void List::createList( ) { |tem * p,* u,*pre; int exp; doubte quot; list=NULL; while(1){ cout<<"输入多项式中的一项(系数、指数):"<<endl; cin>>quot>>exp: if(exp<0)break; //指数小于零,结束输入 if(quot==0)continue; p=list; while( (2) ){ //查找插入点 pre=p;p=p->next;} if(p!=NULL&&exp==p->exp) {p->quot+=quot;continue;} u= (3) ; if(p==list) list=u; else pre->next=u; u->next=p;} } void
[简答题]
阅读以下说明和C++程序,将应填入(n)处的字句写在对应栏内。
【说明】以下程序实现了二叉树的结点删除算法,若树中存在要删除的结点,则删除它,否则返回。 FindNode ( )函数能够在二叉树中找到给定值的结点,并返回其地址和父结点。
【C++程序】
template < class T >
void BinSTree < T >: :Delete( const T& item)
{
TreeNode < T > * DelNodePtr, * ParNodePtr, * RepNodePtr;
if(( DelNodePtr = FindNode (item,ParNodePtr)) = = NULL)
(1)
if(DelNodePtr→right = = NULL) //被删除结点只有一个子结点的情况
RepNodePtr = DelNodePtr→left;
else if( DelNodePtr→left = = NULL)
(2) ;
else // 被删除结点有两个子结点的情况
{
TreeNode < T >* PofRNodePtr = DelNodePtr;
RepNodePtr = DelNodePtr→left;
while(RepNodePtr→right ! = NULL)
{ //定位左子树的最右结点
PofRNodePtr =RepNodePtr;
RepNodePtr = RepNodePtr→right;
}
if(PofRNodePtr = = DelNodePtr) //左子树没有右子结点
(3) ;
else //用左子顷的最右结点替换删除的结点
{
(4)

[简答题][说明] 以下程序实现了在applet里移动图形文件,仔细阅读代码和相关注释,将程序补充完整。 [代码6-1] import j ava. awt. *; import j ava.awt.event.*; import java.applet. Applet; public class AppCIU extends Applet implements MouseMotionListener, MouseListener { Image IMG onClick=over(this) title=放大; // 声明 Image 类类型的变量 IMG onClick=over(this) title=放大 int x=70,y=60,posX=70,posY=60,dx,dy; public void init ( ) { IMG onClick=over(this) title=放大=getImage ( getCodeBase ( ) ,"mouse.gif" ); //载入影像 addMouseListener ( this ); addMouseMotionListener ( this );   } public void mousePressed ( MouseEvent e ) { dx=e.getX( )-posX; //取得按下之点与基准点X方向的距离 dy=e.getY( )-posY; //取得按下之点与基准点Y方向的距离 } public void mouseDragged ( MouseEvent e ) { (1) (2) if ( dx>0 && dx<120 && dy>0 && dy<60 ) //如果指针落在图形上方 { Graphics g=getGraphics ( ); (3) } } public void paint ( Graphics g ) { (4) (5
[单项选择]以下子例行程序用于实现向一维数组下标为P的数组元素处插入一个整数X
SUBROUTINE INSERT(B,N,P,X)
INTEGER B(N),X,P
DO 20 K=N-1,P,-1
B(K+1)=______
20 CONTINUE
B(P)=X
END
为使程序完整,应在______处放入( )。
A. X
B. K
C. B(P)
D. B(K)
[多项选择][说明]
以下程序实现了在applet里移动图形文件,仔细阅读代码和相关注释,将程序补充完整。
[代码6-1]
import j ava. awt. *;
import j ava.awt.event.*;
import java.applet. Applet;
public class AppCIU extends Applet implements MouseMotionListener, MouseListener

Image img; // 声明 Image 类类型的变量 img
int x=70,y=60,posX=70,posY=60,dx,dy;
public void init ( )

img=getImage ( getCodeBase ( ) ,"mouse.gif" ); //载入影像
addMouseListener ( this );
addMouseMotionListener ( this );
 
public void mousePressed ( MouseEvent e )

dx=e.getX( )-posX; //取得按下之点与基准点X方向的距离
dy=e.getY( )-posY; //取得按下之点与基准点Y方向的距离

public void mouseDragged ( MouseEvent e )

(1)
(2)
if ( dx>0 && dx<120 && dy>0 && dy<60 ) //如果指针落在图形上方

Graphics g=getGraphics ( );
(3)


public void paint ( Graphics g )

(4)

[填空题]【说明】 以下程序实现了利用鼠标任意移动该圆形的位置,仔细阅读代码和相关注释,将程序补充完整。 【代码6】 import java.awt.*; import java.awt.event.*; public class CIUSAMPLE extends Frame implements MouseMotionListener, MouseListener { static CIUSAMPLE frm=new CIUSAMPLE ( ); int x=70,y=60,posX=70,posY=60,dx,dy; public static void main ( String args[]) { frm.setTitle ("Dragging a circle"); frm.setSize ( 200,150 ); (1) frm.addMouseMotionListener ( frm ); frm. setVisible ( true ); } public void mousePressed ( MouseEvent e ) { (2) dy=e.getY ( ) -posY; } public void mouseDragged ( MouseEvent e ) { (3) y=e.getY ( ) -dy; if ( dx>0 && dx<50 && dy>0 && dy<50 ) //如果指我落在正方形区域内 { Graphics g=getGraphics ( ); (4) } } public void paint ( Graphics g ) { g.setColor ( Color. pink ); // 设置绘图颜色为粉红 g.fillOval ( x,y,50,50 ); //以基准点为图形的左上角绘出圆形 (5) pos
[简答题][说明]
以下程序实现了利用鼠标任意移动圆形的位置,仔细阅读代码和相关注释,将程序补充完整。
[代码6-1]
import java.awt.*;
import java.awt.event.*;
public class CIUSAMPLE extends Frame implements MouseMotionListener, MouseListener

static CIUSAMPLE frm=new CIUSAMPLE ( );
int x=70,y=60,posX=70,posY=60,dx,dy;
public static void main (String args[])

frm.setTitle ("Dragging a circle");
frm.setSize (200,150);
(1)
ffm.addMouseMotionListener (frm);
frm.setVisible (true);

public void mousePressed (MouseEvent e)

(2)
dy=e.getY ( ) -posY;

public void mouseDragged (MouseEvent e)

(3)
y=e.getY ( ) -dy;
if(dx>0&&dx<50&&dy>0&&dy<50) //如果指针落在正方形区域内

Graphicsg=getGraphics ( );
(4)


public void paint (Graphics g)

g.setColor (Color.pink); //设置绘图颜色为粉红
g.fillOval(x,y,50
[多项选择]【说明】
以下程序实现数据的排序,将n个整数分别按照升序和降序进行排序,类SortInt_1实现升序排序,类SortInt_2实现降序排序。
【Java代码】
class SortInt_1
int i,i,k,temp;
void SortInt(int a1,int a2[])//升序排序
for(i=0;i<a1-1;i++)
k=i;
for(j=i+1;j<a1;j++)
if( (1) ) k=j;
if(k !=i)
temp=a2[i];a2[i]=a2[k];a2[k]=temp;





class SortInt_2 (2)
int i,j,k,temp;
void SortInt(int a1, int a2[])//降序排序
for(i=0; i<a1-1;i++)
k=i;
for(j=i+1;j<a1;j++)
if( (3) )k=j;

if(k !=i)
temp=a2[i];a2[i]=a2[k];a2[k]=temp;




public class test
public static void main(String args[])
int a[]=10,55,100,35,87,90,100,16;
SortInt_1 NewInt= (4) ;
NewInt.SortInt(a.lenvh,a);//调用SortInt_1类的方法
System.out.prin
[简答题][说明] 以下JAVA程序实现了在接口interface iShape2D的定义和应用,仔细阅读代码和相关注释,将程序补充完整。 [代码6-1] interface iShape2D //定义接口 { (1) (2) } (3) //实现CRectangle类 { int width, height; (4) CRectangle (int w,int h) { width=w; height=h; } public void area ( ){ //定义area( )的处理方式 System. out.println ("area="+width*height); } } (5) //实现CCircle类 { double radius; (6) CCircle (double r) { radius=r; } public void area ( ) { //定义area( )的处理方式 System.out.println ("area="+pi*radius*radius); } } [代码6-2] public class app10_4 { public static void main(String args[]) { CRectangle rect=new CRectangle (5,10); rect.area ( ); //调用CRectangle类里的area ( ) method CCircle cir=new CCircle (2.0); cir.area ( ); //调用CCircl类里的area ( ) method } }
[简答题][说明]
以下JAVA程序实现了在接口interface iShape2D的定义和应用,仔细阅读代码和相关注释,将程序补充完整。
[代码6-1]
interface iShape2D //定义接口

(1)
(2)

(3) //实现CRectangle类

int width, height;
(4) CRectangle (int w,int h)
width=w;
height=h;

public void area ( ) //定义area( )的处理方式
System. out.println ("area="+width*height);


(5) //实现CCircle类

double radius;
(6) CCircle (double r)
radius=r;

public void area ( ) //定义area( )的处理方式
System.out.println ("area="+pi*radius*radius);


[代码6-2]
public class app10_4

public static void main(String args[])

CRectangle rect=new CRectangle (5,10);
rect.area ( ); //调用CRectangle类里的area ( ) method
CCircle cir=new CCircle (2.0);
cir.area ( ); //调用CCircl类里的area ( ) method


[填空题]下列程序段用于实现以下功能:随机产生一个100以内的整数,从键盘上输入一个数,计算机提示输入的数是否与随机整数一样。请填空。
Private Sub Command1_Click( )
RANDOMIZE
a = 【1】
Do
Input "请输入一个数字:", n
If n = a Then
Print "Good!"
【2】
ElseIf n>a Then
Print "大了"
Else
Print "小了"
End If
Loop
End Sub

我来回答:

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

订单号:

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