dkfr.net
当前位置:首页 >> 编写程序:随机产生10个整数并存入数组中,用"选择排... >>

编写程序:随机产生10个整数并存入数组中,用"选择排...

#includevoid main(){ int a[10],i,j,t,k; for(int i=0;i

#include #include #include int main(){ int a[10], i, sum = 0; srand((unsigned int)time(NULL)); for (i = 0; i < 10; ++i){ a[i] = rand(); } printf ("随机产生的10个数是:\n"); for (i = 0; i < 10; ++i){ sum += a[i]; printf ("%d\n",...

Private Sub RandomizeAndSort() Dim a(1 To 10) As Integer Dim i As Integer, j As Integer ' 生成 10 个整数类型的随机数 Randomize For i = 1 To 10 a(i) = Int(Rnd * 90) + 10 Next '显示 Debug.Print "排序前" For i = 1 To 10 Debug.Prin...

Private Sub Command3_Click() '用VB编程:随机产生10个0~100之间的随机整数,存放在一个数组中, '然后求个元素和、平均值,统计 '大于平均值的元素个数并把它们显示出来? Dim MyValue(100) As Integer Dim i As Integer Dim n As Integer Dim ...

#include"stdio.h" void main() {int a[10],i,j,m; printf("please enter the number:\n"); for(i=0;i

我用C代码实现的,你直接把代码拷贝到VC/VS上即可。 我把随机数产生、冒泡排序、显示函数 都分别封装成了函数,注释写得比较清楚 #include #include #include void BubbleSort(int *p); void display(int *p); void Random(int *p); int main() ...

Sub x() Dim arr(1 To 10) As Integer, i, j, k '产生随机数 For i = LBound(arr) To UBound(arr) arr(i) = Int(Rnd * 100) Next i MsgBox "随机生成的数据是:" & Join(arr, ",") '排序 For i = LBound(arr) To UBound(arr) - 1 k = i For j = ...

#include int main() { int a[10],i,j; for(i=0;i

#includevoid ssort(int a[], n){ int i,j,k; for(i=0;i

public class TestBaiduKnow {public static void main(String[] args) {int[] a = { 9, 8, 7, 10, 6, 5, 4, 3, 2, 1 };System.out.println("原始数组:");for (int i = 0; i < a.length; i++)System.out.print(a[i] + " ");for (int i = 0; i <...

网站首页 | 网站地图
All rights reserved Powered by www.dkfr.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com