#include
#include
#include
#define N 10
void main()
{
int a,i,max=0,min=100,num=0;
srand(time(NULL));
for(i=0;i
a=rand()%100+1;
num+=a;
if(a>max) max=a;
if(a
num/=N;
printf("最大值是:%d,最小值是:%d,平均值是:%d\n",max,min,num);
}
我的就是C
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.IO;
namespace StudyRandom
{
class Program
{
public static int GetRandom()
{
Thread.Sleep(25);
Random r = new Random();
return r.Next(1, 100);
}
static void Main(string[] args)
{
int[] myArray = new int[10];
int max =myArray[0];
int min = myArray[0];
int count = 0;
int countM=0;
for(int i=0;i<10;i++)
{
myArray[i] = GetRandom();
Console.WriteLine(myArray[i]);
if (myArray[i] > max)
{
max = myArray[i];
}
if (myArray[i] < min)
{
min = myArray[i];
}
count = max + min;
countM += myArray[i];
}
Console.WriteLine("最大值max=" + max);
Console.WriteLine("最小值min=" + min);
Console.WriteLine("最大值和最小值的和" + count);
Console.WriteLine("平均值" + countM / 10);
Console.ReadLine();
}
}
}
这是C#版本的
Private Sub Command1_Click()
Dim a(9)
Sum = 0
Randomize
For i = 0 To 9
a(i) = Int(Rnd * 100) + 1
Print a(i);
Sum = Sum + a(i)
Next i
Min = a(0)
Max = a(0)
For i = 1 To 9
If a(i) < Min Then
Min = a(i)
End If
If a(i) > Max Then
Max = a(i)
End If
Next i
Print
Print "最大值" & Max
Print "最小值" & Min
Print "和" & Sum
End Sub