题目内容

在类中定义和实现的函数可以称为【 】。

查看答案
更多问题

大众包餐公司实施准时化服务有无困难,请加以解释。

下列给定程序中,函数fun的功能是按以下递归公式求函数值。
例如:当给n输入5时,函数值为240;当给n输入3时,函数值为60。
请改正程序中的错误,使它能得到正确结果。
注意;不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
include <stdio.h>
/*************found****+*******/
fun(int n);
{
int c;
/*************found********+*****/
if(n=1)
c=15;
else
c=fun(n-1)*2;
return(c);
}
main()
{
int n;
printf("Enter n:");
scanf("%d",&n);
printf("The result:%d\n\n",fun(n));
}

下面是一个Applet程序,程序的功能是显示一个圆心在Applet的中心,半径从0到100像素的不断变大的蓝色球的动画。请改正程序中的错误(有下划线的语句),使程序执行后,能得到预期的结果。
注意:不改动程序的结构,不得增行或删行。
程序的执行结果为:
import java.awt.*;
import java.applet.*;
/*
<applet code=XiaoQiu width=800 height=600>
</applet>
*/
public class XiaoQiu extends Applet implements Runnable
{
int currentX=0,currentY=0;
Thread m_Draw=null;
public void init()
{
m_Draw=new Thread (super);
}
public void paint(Graphics g)
{
g.setColor(Color.blue);
mycircle(g,getSize().width/2,getSize().height/2,currentX,currentY);
}
public void start()
{
m_Draw.start();
try
{
Thread.sleep(500);
}
catch(InterruptedException e){}
}
public void stop()
{
if(m_Draw.isAlive())
m_Draw. stop();
}
public void run()
{
try
{
while(true)
{
currentX++;
currentY++;
if(currentX>i00&&(currentY>100))
{
currentX=0;
currentY=0;
}
paint();
Thread.sleep(100);
}
}
catch(InterruptedException e){}
}
public void mycircle(Graphics g,int x,int y,int rx, int ry)
{
g.filloval(x-rx,y-ry,2*rx,2*ry);
}
}
ex3 9_3. html:
<html>
<head>
<title>A Simple Program</title>
</head>
<body>
<applet cede=" XiaoQiu.class" width=800 height=400>
</applet>
</body>
</html>

若有以下程序:
include <iostream>
using namespace std;
class sample
{
int x;
public:
sample(){}
void setx(int i)
{
x=i;
}
friend iht fun(sample B[],int n)
{
int m=0;
for{int i=0;i<n;i++)
if(B[i].x>m)
m=B[i].x;
return.m;
}
};
int main ()
{
sample A[10];
int arr[]={90,87,42,78,97,84,60,55,78,65};
for(int i=O;i<10;i++)
A[i].setx(arr[i]);
cout<<fun(A, 10)<<end1;
return 0;
}
该程序运行后的输出结果是【 】。

答案查题题库