更多"[说明]
以下程序实现了利用鼠标任意移动圆形的位置,仔细阅读代码和"的相关试题:
[填空题]【说明】
以下程序实现了利用鼠标任意移动该圆形的位置,仔细阅读代码和相关注释,将程序补充完整。
【代码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 );
[简答题][说明]
以下程序实现了利用鼠标任意移动圆形的位置,仔细阅读代码和相关注释,将程序补充完整。
[代码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
[简答题][说明]
以下程序实现了在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
[简答题][说明]
以下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
[简答题][说明]
以下代码实现了对象引用作为函数参数,仔细阅读以下代码,分析运行结果,填入 (n) 处。
[代码]
#include<iostream.h>
class Sample
int x,y;
public:
Sample( ) x=y=0;
Sample (int i, int j ) x=i; y=j;
void copy ( Sample &s ).,
void setxy ( int i, int j ) x=i; y=j;
void print ( cout<<"x="<<x<<end1 ; cout <<"y="<<y<<end1;
;
void Sample: copy ( Sample &s )
X=S.X;
y=s.y;
void func ( Sample s1, Sample &s2 )
s1.setxy ( 10,20 );
s2.setxy ( 30,40 );
void main ( )
Sample p ( 1,2 ) ,q;
q.copy ( p );
time ( p,q );
p.print ( );
q.print ( );
运行结果
(1)
(2)
(3)
(4)
[简答题]【说明】
以下程序实现数据的排序,将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.println("升序排列的数据: ");
for(int i=0;i<a.length;i++){
System.out.print(a[i]+
[多项选择]【说明】
以下程序实现数据的排序,将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
[简答题][说明]
下面代码实现类A、B、C、D的继承定义和应用。仔细阅读[代码5-1],在 (n) 处写出正确的运行结果。
[代码5-1]
#include<iostream.h>
class A {
public:
int a;
A (int v1): a(v1) {} //构造函数
void disp ( )
{
cout<<"a in class A="<<a<<endl;
}
};
class B: virtual public A {
public:
int b;
B (int v1,int v2): A(v1),b v2) {} //构造函数
void disp ( )
{
cout<<"a in class B="<<a<<endl
cout<<"b in class B="<<b<<endl;
}
};
class C: virtual public A {
public:
int c;
C (int v1,int v2): A(v1) ,c(v2) {} //构造函数
void disp ( )
{
cout<<"a in class C="<<a<<endl;
cout<<"c in class C="<<c<<endl;
}
};
class D: public B, public C {
public:
int d;
D (int v1,int v2,int v3,int v4 ): A(v1) ,B(v1,v2) ,C(v1,v3),d(v4) {} //构造函数
void disp ( )
{
cout<<"a="<<a<<endl;
cout<<"b="<< b<<endl;
cout<<"c="<<c<<endl;
cout<<"d="<<d<<endl;
}
};
void main( )
{
D demo (10,20,30,40);
demo.disp ( );
}
[运行
[填空题]以下程序实现的功能是 【4】 ,结果存放在AX中。
START: IN AL,20H
MOV BL,AL
IN AL,30H
MOV CL,AL
MOV AX,0
NEXT: ADD AL,BL
ADC AH,0
DEC CL
JNZ NEXT
HLT
[填空题]以下程序实现的功能是 【4】 ,结果存放在AX中。
START: IN AL,20H
MOV BL,AL
IN AL,30H
MOV CL,AL
MOV AX,0
NEXT: ADD AL,BL
ADC AH,0
DEC CL
JNZ NEXT
HLT
[多项选择]期货公司在接受客户开户申请时,必须向客户提供“期货交易风险说明书”,客户应仔细阅读并理解。以下说法正确的是()。
A. 单位客户应在该“期货交易风险说明书”上签字并加盖单位公章,可以由单位法定代表人授权他人签字
B. 单位客户应在该“期货交易风险说明书”上签字并加盖单位公章,可以由单位法定代表人签字
C. 个人客户可授权他人在该“期货交易风险说明书”上签字
D. 个人客户应亲自在该“期货交易风险说明书”上签字
[单项选择]警示语为“请仔细阅读药品使用说明书并按说明使用”的药品是
A. 处方药
B. 非处方药
C. 乙类非处方药
D. 甲类非处方药
E. 传统药
[填空题]设函数findbig已定义为求3个数中的最大值。以下程序将利用函数指针调用findbig函数。请填空。
main( )
int findbig(int,int,int);
int (*f) ( ) ,x,y, z,big;
f=______;
scanf("%d%d%d",&x,&y,&z:
big=(*f)(x,y,Z);
printf("big=%d/n",big);
[填空题]设函数findbig( )已定义为求3个数中的最大值。以下程序将利用函数指针调用findbig函数。请填空。
main( )
{ int findbig(int,int,int);
int (*f)( ),x,y,z,big;
f=【 】;
scanf("%d%d%d",&x,&y,&z);
big=(*f)(x,y,z);
printf("big=%d/n",big);
}