下列程序的运行结果sum的值为()Int i=1,sum=0;While(i<=10){if(i>=5) break;sum+=i;i++;}System.out.println(“sum结果为”+sum)
A.9
B.10
C.11
D.12
10
A.9
B.10
C.11
D.12
10
A.sum = 25
B.sum = 45
C.sum = 15
D.sum = 9
A.8
B.7
C.5
D.6
阅读下列程序,请写出程序的运行结果。
import java.applet.*;
import java.awt.*;
public class C extends Applet implements Runnable
{
Thread redBall,blueBall;
Graphics redPen,bluePen;
int blueSeta=0,redSeta=0;
public void init()
{
setSize(250,200);
redBall=new Thread(this);
blueBall=new Thread(this);
redPen=getGraphics();
bluePen=getGraphics();
redPen.setColor(Color.red);
bluePen.setColor(Color.blue);
setBackground(Color.gray);
}
public void start()
{
redBall.start();
blueBall.start();
}
public void run()
{
intx,y;
while(true)
{
if(Thread.currentThread()==redBall)
{//以下代码为顺时针画圆
x=(int)(80.0*Math.cos(3.1415926/180.0*redSeta));
y=(int)(80.0*Math.sin(3.1415926/180.0*redSeta));
redPen.setColor(Color.gray);
redPen.fillOval(100+x,100+y,10,10);
redSeta+=3;
if(redSeta>=360)redSeta=0;
x=(int)(80.0*Math.cos(3.1415926/180.0*redSeta));
y=(int)(80.0*Math.sin(3.1415926/180.0*redSeta));
redPen.setColor(Color.red);
redPen.fillOval(100+x,100+y,10,10);
try{redBall.sleep(20);}
catch(InterruptedException e){}
}
elseif(Thread.currentThread()==blueBall)
{//以下代码为顺时针画圆
x=(int)(80.0*Math.cos(3.1415926/180.0*blueSeta));
y=(int)(80.0*Math.sin(3.1415926/180.0*blueSeta));
bluePen.setColor(Color.gray);
bluePen.fillOval(150+x,100+y,10,10);
blueSeta-=3;
if(blueSeta<=-360)blueSeta=0;
x=(int)(80.0*Math.cos(3.1415926/180.0*blueSeta));
y=(int)(80.0*Math.sin(3.1415926/180.0*blueSeta));
bluePen.setColor(Color.blue);
bluePen.fillOval(150+x,100+y,10;10);
try{blueBall.sleepp(40);}
catch(InterruptedException e){}
}
}
}
}
阅读以下程序,填写运行结果()。lst=[(1,3),(4,2),(6,8),(3,0)] lst.sort(key=lambda i:sum(i)) print(lst[2])
找最值 题目内容: 从键盘任意输入6个整数,用指针变量作函数参数编程计算最大值和最小值,并返回它们所在数组中的位置。函数原型如下所示: int FindMax(int num[], int n, int *pMaxPos);//函数返回最大值,pMaxPos返回最大值所在的下标 int FindMin(int num[], int n, int *pMinPos);//函数返回最小值,pMaxPos返回最小值所在的下标 程序运行结果示例: Input 10 numbers: -1 2 3 45 92 8 9 ↙ Max=92,Position=4,Min=-1,Position=0 输入格式: "%d" 输出格式: 提示信息:"Input 6 numbers:\n" 输出结果:"Max=%d,Position=%d,Min=%d,Position=%d\n"
A.s=10
B.10
C.55
D.s=55
A.5 8 12 15 30
B.12 15 5 30 18
C.8 12 15 30 18
D.12 15 5 18 30
class Matrix {
public:
Matrix(int row,int col); // 构造一个具有row 行col 列的矩阵
~Matrix() {delete []mem;} // 析构函数
friend bool Multiply(Matrix &m1, Matrix &m2, Matrix &m3);
// 定义Multiply() 为友元函数,该函数把m1×m2的值赋给m3
// 其他成员函数从略
private:
int *mem; // 动态申请矩阵空间
const int rows,cols; // 矩阵的行数和列数
};
Matrix::Matrix(int row,int col):rows(row),cols(col)
{
mem = new int[row*col];
}
bool Multiply(Matrix &m1, Matrix &m2, Matrix &m3)
{
// 确定矩阵是否能够进行相乘
if(m1.rows != m3.rows ||m2.cols != m3.cols || m1.cols != m2.rows) return false;
// 定义sum变量,用于计算乘积矩阵m3中每个元素的值
int sum;
// 请在下面编写剩余部分
}