Private Sub Command1_Click()
Dim a(29) As Integer, tmp As Integer
Dim i As Integer, j As Integer
Randomize Time
For i = 0 To 29
a(i) = Int(Rnd 71) + 30
Next
For i = 0 To 29
For j = i To 29
If a(i) > a(j) Then
tmp = a(i)
a(i) = a(j)
#include <stdioh>
#include<stdlibh>
#include<timeh>
int main(){
int a[50];
int sum=0;
srand((int)time(NULL));
for(int i=0;i<50;i++)
{
a[i] = (rand()%90)+10;
if(a[i]%7==0)
sum++;
printf("%d ",a[i]);
if((i+1)%10==0)
printf("\n");
}
printf("sum=%d",sum);
}
Dim a(1 To 50) As Integer
Private Sub Command1_Click()
Randomize
For i = 1 To 50
a(i) = Int(Rnd 50) + 1
Text1 = Text1 & a(i) & " "
If i Mod 10 = 0 Then Text1 = Text1 & vbCrLf
Next i
Text2 = Max
End Sub
Private Sub Command2_Click()
For i = 1 To 50
If i = 1 Then Max = a(1)
If a(i) > Max Then Max = a(i)
Next i
Text2 = Max
End Sub
Private Sub Form_Load()
Text1 = ""
Text2 = ""
End Sub
打码不容易望采纳谢谢。。。
#include <stdioh>#include <stdlibh>
#include <timeh>
#define random(x) (rand()%x)
/ run this program using the console pauser or add your own getch, system("pause") or input loop /
int main(int argc, char argv[]) {
srand((unsigned) time(NULL)); //用时间做种,每次产生随机数不一样
int result[50];
printf("随机产生范围1,99内的正整数数组 :\n");
int i=0;
int length=50;
for(;i<length;i++){
result[i]=random(89)+1;
printf("%d ",result[i]);
}
printf("\n");
printf("每10个一行形式打印数组:\n");
i=0;
for(;i<length;i++)
{
printf("%2d ",result[i]);
if((i+1)%10==0)
printf("\n");
}
system("pause");
return 0;
}
由于题目不完整,我只是猜想你要的结果
import javautilArrays;import javautilRandom;
public class SumTest {
public static void main(String[] args) {
Random r = new Random();
int[] arr = new int[50];
int start = 10, end = 100, max = 0, sum = 0;
for (int i = 0; i < arrlength; i++) {
arr[i] = rnextInt(end - start + 1) + start;
max = arr[i] < max max : arr[i];
sum += arr[i];
}
Systemoutprintln(ArraystoString(arr));
Systemoutprintln("最大值:" + max + ";50个值的总和:" + sum);
}
}
以上就是关于用随机函数产生50个[10,100 )的随机整数,并按照由小到大的顺序打印出来。 程序界面如下:全部的内容,包括:用随机函数产生50个[10,100 )的随机整数,并按照由小到大的顺序打印出来。 程序界面如下:、随机产生50个两位整数(10~99范围内)存入a数组中,以每行10个数输出,、VB编程实现:运行时,单击第一个按钮,生成50个[1,50]之间的随机整数等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)