#include"stdio.h"
#include"time.h"
void main()
{
int n ,a[50],i,j,t
srand(time (NULL))
for(i=0i<50i++)
{
a[i]=rand()%90+10
for(j=0j<i-1j++)
if (a[i]==a[j])
i--
}
printf("nafter:\n")
for(i=0i<50i++) // 下面这是打印输出
{
if (i%5==0)// 十个数字换行
printf("\n")
printf("%d ",a[i])
}
return 0
}
#include<stdio.h>#include<math.h>
void main()
{
int x
int i
int f
for(i=1i<=50i++)
{
f=rand()
x=f%(99-10+1)+10
printf(''%d'',x)
if(i%5==0)
printf(''\n'')
}
}
Dim n As Integer, i As Integer, x As IntegerDim s1 As String, s2 As String
Randomize
For i = 1 To 50
x = Int(Rnd * 50) + 1
s1 = s1 &x
If i Mod 10 = 0 Then
s1 = s1 &vbCrLf
Else
s1 = s1 &" "
End If
If x Mod 6 = 2 Then
n = n + 1
s2 = s2 &x
If n Mod 10 = 0 Then
s2 = s2 &vbCrLf
Else
s2 = s2 &" "
End If
End If
Next
Print "产生的50个随机数如下"
Print s1
Print "其中被6除余2的数有" &n &"个"
Print s2
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)