更多"以下程序的功能是:生成20个200~300之间的随机整数,输出其中能被"的相关试题:
[填空题]以下程序的功能是:生成20个200到300之间的随机整数,输出其中能被5整除的数并求出它们的和。请填空。
Private Sub Command1_Click( )
For i=1 To 20
x=Int( 【6】 *100+200)
If 【7】 =0 Then
Print x
S=S+ 【8】
End lf
Next i
Print"Sum=";S
End Sub
[填空题]以下程序代码实现单击命令按钮Command1时生成20个(0,100)之间的随机整数,存于数组中,打印数组中大于50的数,并求这些数的和。
Dim arr(1 To 20)
For i=1 To 20
arr(i)= 【12】
Next i
Sum=0
For Each X In 【13】
If X>50 Then
Print Tab(20);X
Sum=Sum+X
End If
Next X
Print Tab(20);“Sum=”;Sum
[简答题]本题程序的功能是随机产生一个1~10的随机数,根据提示,用户可以猜这个随机数。例如程序随机产生的随机数是7,如果输入8,则提示“Try smaller…”并继续提示输入;如果输出6,则提示“Try bigger…”并继续提示输入;如果输入7,则会输出“Great!”并退出程序。请将下述程序补充完整(注意:不得改动程序的结构,不得增行或删行)。
import java.io.*;
public class basic
public static void main(String[] args)
InputStreamReader it;
Bur feredReader in;
Ir = new InputStreamReader(System.in)
In = new BufferedReader(ir);
int ranNum = ______;
int guessNum = -1;
String str;
while (______)
System.out.print ("Please Input:");
try
______;
guessNum = Integer.parseInt(str);
catch (Exception e)
if(guessNum > ranNum)
System.out.println("Try smaller...");
else
System.out.println("Try bigger...");
System.out.println ("Great ! ");
[填空题]下列程序的功能是:单击窗体时将随机生成10个1~100之间的数,求出它们的总和及平均数。请填空。
Option Base 1
Private Sub Form_Click( )
Dim a(10)As Integer,i As Integer
Dim sum As Integer,aver As Single
【12】
For i=1 To 10
a(i)=Int(100*Rnd)+1
sum=sum+a(i)
Next i
【13】
Print sum,aver
End Sub
[单项选择]下列程序代码实现生成20个0~100之间的随机整数,存于数组中,打印数组中大于50的数,并求这些数的和。请选择正确的程序段是( ),完成程序。 Private Sub Command1_Clickn Dim arr(1 To 20) For i=1 To 20 arr(i)=______ Text1.Text=Text1.Text&arr(i)&Chr(13)&Chr(10) Next i Sum=0 For Each X______ If X>50 Then Print Tab(20);X Sum=Sum+X End If Next X Print Tab(20);"Sum";Sum End Sub
A. Int(Rnd*99+1) In arr
B. Int (Rn In arr
C. Int(Rnd*99+1) In arr()
D. Int(Rn In arr()
[简答题]在程序中,用户使用JOptionPane输入一个二维数组的行数,程序随机生成每一行的列数,并对其赋值。最后显示这个二维数组。请填写横线处的内容。
注意:请勿修改main( )主方法和其他已有语句内容,仅在横线处填入适当语句。
import javax.swing.*;
public class basic
{
public static void main(String[] args)
{
String sDimU=JOptionPane.showInputDialog("请输入数组的行数");
int iDimU=______(sDimU);
int [].[] numbers=new int[iDimU] [];
for(int i=0; i<iDimU; i++)
{
int k=(int) (Math.random( )*5+1);
numbers[i]=______;
}
for(int i=0; i<iDimU; i++)
{
for(int j=0;______; j++)
{
numbers[i] [j]=(int) (Math.random( )*l00);
System.out.print(numbers[i] [j]+" ");
}
System.out.println ( );
}
System.exit(O)
}
}
[简答题]下列程序中,用户使用JOptionPane输入一个二维数组的行数,程序随机生成每一行的列数,并对其赋值。最后显示这个二维数组。请填写横线处的内容。
注意:请勿改动main( )主方法和其他已有语句内容,仅在横线处填入适当语句。
import javax.swing.*;
public class Examplel_10
{
public static void main (String[] argv)
{
String sDimU = JOptionPane. showInputDialog ("请输入数组的行数");
int iDimU = __________ (sDimU);
int [] [] numbers = new int[iDimU] [];
for(int i = 0; i < iDimU; i++)
{
int k = (int) (Math.random( ) *5+1);
numbers [i] = ____________;
}
for(int i = O; i < iDimU; i++)
{
for(int j = 0; _________; j++)
{
numbers[i] [j] = (int) (Math.random( )*100);
System.out.print(numbers[i] [j] + " ");
}
System.out.println( );
}
System.exit(O);
}
}
[单项选择]下面程序的功能是由随机函数产生100个在200~700之间的整数,然后找出最大者,并记下是第几个数,但程序不完整,请选择适当的内容在下划线处将程序补充完整。 Dim a(100) For j=1 To 100 a(j)=Int(Rnd*501+200):Print a(j) Next j : Print p=1 : max= ______ For j=2 To 100 If a(j)>max Then max=a(j) : p=j Next j Print "The largest number is " ; max Print "The position is"; p End
A. 0
B. a(1)
C. 1.7E+38
D. 1.7E-38
[填空题]
以下程序用来产生20个(0,99)之间的随机整数,并将其中的偶数打印出来。请填空。
Private Sub Command1_Clcik( )
Randomize
For I=1 To 20
X=Int(Rnd*_(1)_)
If X/2=_(2)_Then Print x
Next I
End Sub
(1)()
[简答题]本题程序的功能是随机产生50个0~100间的随机数,并计算70~80间随机数的个数(包括70,不包括80)。请将下述程序补充完整(注意:不得改动程序的结构,不得增行或删行)。
public class basic
public static void main(String[] args)
int result = 0;
int i = 0;
int randomNum;
while (i<50)
randomNum =______;
if(______)
result ++;
______;
System.out.println("result =" + result);
[填空题]下列程序的功能是:单击窗体时随机生成20个两位数依次赋值给一个由20个元素组成的数组,然后把数组反序存放,再输出。
Option Base 1
Private Sub Form Click( )
Dim a(20)As Integer,i As Integer
Dim t As Integer,j As Integer
Randomize
For i=1 To 20
a=10+Int(90*Rnd)
Print a(i);
Next
Print
i=1: 【4】
Do While i<j
t=a(i): 【5】 a(j)=t
i=i+1: j=j-1
Loop
For i=1 To 20
Print a(i);
Next i
Print
End Sub
[填空题]下列程序的功能是,单击命令按钮时随机生成15个100以内的正整数,放到3×5的数组中,找出该数组中最大的元素,并指出该元素的行标和列标。请填空。
Option Base 1
Private Sub Command1_Click( )
Dim a(1 To 3, 1 To 5) As Integer, n As Integer, m As Integer
Dim maximum As Integer, max n As Integer, max_m As Integer
Randomize
For m=1 To 3
For n = 1 To 5
a(m, n)= 【3】
Next n
Next m
maximum=a(1, 1)
max n=1 : max m=1
For i = 1 To 3
For j=1 To 5
If 【4】 Then
maximum=a(i, j)
max m=i
max_n=j
End If
Next j
Next i
Print maximum, max m, max n
End Sub
[填空题]以下程序的功能是在立即窗口中输出100~200之间所有的素数,并统计输出素数的个数。请在程序空白处填入适当的语句,使程序可以完成指定的功能。
Private Sub Command2_Click( )
Dim i%,j%,k%,t% ’t为统计素数的个数
Dim b AS Boolean
For i=100 T0 200
b=True
k=2
J=Int(Sqr(i))
Do While k<=j And b
If i Mod k=0 Then
b= (12)
End If
k= (13)
Loop
If b=True Then
t=t+1
Debug.Print i
End If
Next i
Debug.Print"t=";t
End Sub