1樓:匿名使用者
好吧,沒有研究過。不過用隨機函式加氣泡排序法應該可以做出來的吧。同求,希望高手們寫注釋啊!
2樓:匿名使用者
private sub command1_click()clsdim a(1 to 10) as integerfor i = 1 to 10
randomize
a(i) = int(rnd * 90 + 10)for j = 1 to i - 1
if a(i) = a(j) then
i = i - 1
exit for
end if
next j
next i
print "產生的隨機數為:"
for i = 1 to ubound(a)print a(i);
next i
for i = 1 to ubound(a) - 1for j = ubound(a) to i + 1 step -1if a(i) > a(j) then b = a(i): a(i) = a(j): a(j) = b
next j
next i
print "排序後的數為:"
for i = 1 to ubound(a)print a(i);
next i
end sub
3樓:
private sub command1_click()dim a(10)
for i = 1 to 10
doa(i) = int(rnd * 90) + 10for j = 1 to i - 1
if a(i) = a(j) then exit fornext
loop while j < i
next
for i = 1 to 10
for j = 1 to i
if a(i) < a(j) then t = a(i): a(i) = a(j): a(j) = t
next
next
for i = 1 to 10
print a(i);
next
end sub
vb編寫程式 隨機產生10個10—99之間的的任意整數,並按從大到小的順序輸出。
4樓:曦者
private sub command1_click()dim m(9) as integer
dim a as integer
dim i as integer
dim j as integer
a = 0
for i = 0 to 9
m(i) = 10 + int(rnd * 89)next
text1.text = m(0) & "," & m(1) & "," & m(2) & "," & m(3) & "," & m(4) & "," & m(5) & "," & m(6) & "," & m(7) & "," & m(8) & "," & m(9)
for i = 0 to 9
for j = i to 8
if m(i) < m(j + 1) thena = m(i)
m(i) = m(j + 1)
m(j + 1) = a
end if
next j
next i
text2.text = m(0) & "," & m(1) & "," & m(2) & "," & m(3) & "," & m(4) & "," & m(5) & "," & m(6) & "," & m(7) & "," & m(8) & "," & m(9)
end sub
5樓:笨笨的凱凱
重置隨機數沙盒,把10個數放入陣列。氣泡排序。ok
vb編寫程式 隨機產生10∼99間 10個整數 選擇法 遞增順序
6樓:匿名使用者
直接在網頁中寫**了
新建乙個工程
form1上放乙個command1,乙個list1用來顯示隨機產生的整數
private sub command1_click()
dim a(9) as integer '定義陣列a用來存放隨機產生的10個數
dim temp as integer
for i = 0 to 9randomize
a(i) = int(rnd * 89 + 10) '隨機生成乙個10-99之間的整數
next
for i = 0 to 9
for j = i+1 to 9
if a(i) > a(j) then '對這10個數進行排序
temp = a(i)
a(i) = a(j)
a(j) = temp
next
next
for i = 0 to 9
list1.additem a(i) '將這10個數按大小順序新增到listbox1中
next
end sub
用指標實現:由鍵盤輸入10個整數,將他們按由小到大的順序排列。
7樓:問明
#include
void sort(int*s,int n);//定義排序函式int main()
int a[10],*p;
printf("please enter 10 nunmbers:");//輸入10個整數
for(p=a;pprintf("original number:");
for(p=a;pprintf("\n");
sort(a,10);//呼叫排序函式
printf("new number:");
for(p=a;pprintf("\n");
return 0;
void sort(int*s,int n)int*i,*j,t;
for(i=s;ifor(j=i+1;j
8樓:老馮文庫
/* 用指標實現:由鍵盤輸入10個整數,將他們按由小到大的順序排列 */
#include "stdio.h"
/* 簡單選擇排序 */
void selectsort(int *arr, int len)if(k != i)}}
void main()
9樓:匿名使用者
#include/* 用指標實現:由鍵盤輸入10個整數,將他們按由小到大的順序排列 */
void main() /*主函式*/
}for( i = 0 ; i <= 9 ; i++ ) /*排序後輸出結果*/
printf( "%d" , *(p+i) );
} /*the end*/
10樓:匿名使用者
#include
void main()
int order(int *p1,int *p2,int *p3,int *p4,int *p5,int *p6,int *p7,int *p8,int *p9,int *p10)
while(i<10);
return(*p1,*p2,*p3,*p4,*p5,*p6,*p7,*p8,*p9,*p10);
}int ord(int *pa,int *pb)return(*pa,*pb);}
11樓:匿名使用者
#include"stdio.h"
int main()
void sort(int *p)}
12樓:重新開始
#include
void swap(int*p,int*q)void main()
swap(&a[0],max);
swap(&a[9],min);
for(i=0;i<10;i++)
printf("%4d",*(a+i))}
13樓:匿名使用者
#include
void sort(int a,int n)}void sc(int x,int n)}int main(void)
sort(x,n);
sc(x,n);
printf("\n");
return 0;}
14樓:查水瑤
#include
#include
int cmp(const void *a,const void *b)
int main(void)
qsort(p,10,sizeof(int),cmp);
while(p
編寫程式,隨機生成50個兩位整數,按每行10個輸出
5 15樓:匿名使用者 #include #include void main()} 16樓:匿名使用者 給採納,給你=寫~ - - 利用高階語言程式設計(vb)隨機函式產生90個10~99之間的隨機整數,將其中的偶數按由小到大的順序排列… 求vb 程式設計利用隨機函式產生80個10~99之間的隨機整數,將其中的偶數按由小到大的順序排列並輸出,將奇 17樓: 這是我做的,你參考一下。 用vb編寫*利用隨機函式產生20個10~99之間(包括10和99)的隨機整數存入一維陣列a, 18樓:匿名使用者 dim n ,m,a(19),max max=0 for n=0 to 19 a(n)=int((rnd*90)+10) '生成20個10-99的隨機數 next n for n=0 to 18 for m=n+1 to 19 if a(n)>a(m) then swap a(n),a(m) 『排序從小到大end if next m next n for n=1 to 19 if a(n)-a(n-1)>max thenmax=a(n)-a(n-1) 』計算相差最大值,賦值給maxend if next n 19樓:幸福答案 '只須在窗體內忝加乙個command即可 private sub command1_click()clsdim a(1 to 20), b(1 to 19)randomize print "隨機生成的這組數是:" for i = 1 to 20 a(i) = int(rnd * 90) + 10print a(i); if i = 10 then print next print print print "這組數按從大到小的順序排列每10人一行輸出如下:" for i = 1 to 20 for j = i + 1 to 20 if a(i) < a(j) then t = a(i): a(i) = a(j): a(j) = tend if next print a(i); if i mod 10 = 0 then printnext for i = 1 to 19 b(i) = a(i) - a(i + 1)next x = b(1) for i = 1 to 19 if x < b(i) then x = b(i)next print print "相鄰兩個數的最大差值是:" & xend sub 20樓: dim i%, j%, a%(20), max%max = 0 randomize for i = 1 to 20 a(i) = int((rnd * 90) + 10) '生成20個10-99的隨機數 print a(i); next i for i = 1 to 19 for j = i + 1 to 20 if a(i) > a(j) then t = a(i): a(i) = a(j): a(j) = t '排序從小到大 end if next j next i print for i = 1 to 20 print a(i); next i for i = 2 to 20 if a(i) - a(i - 1) > max thenmax = a(i) - a(i - 1) '計算相差最大值,賦值給max end if next i print print "max="; max 我用兩個文字框和乙個命令按鈕來實現 其中文字框 text1 用來存放 輸入資料 text2用來存放處理後的結果 用command1實現以上功能 private sub command1 click text2.text val text1.text 10end sub 你把要求說的不太詳細,我只是按... 瘋狂小鳥 如圖所示,望採納。 冉冉曦丶 imports system.math public class form1 private sub button1 click sender as object,e as eventargs handles button1.click dim a,b as ... 直接呼叫以下函式過程即可 二進位制轉十進位制 public function b2d vbstr as string as long dim vlen as integer 串長 dim vdec as long 結果 dim vg as long 權值 dim vi as long 位數 dim ... 1900年到2200年之間的所有閏年顯示在窗體中的命令 dim i as integer for i 1900 to 2200 if i mod 4 0 and i mod 100 0 or i mod 400 0 then lst.additem i end if next i 採用的vb的變數進... 看的頭暈 if a b then if b c then goto s else if a c then n b b c c n goto s else n b b a a c c n goto s end if end if else if b c then n a a c c n goto s ...用vb語言編寫程式,用VB語言編寫程式
用vb語言編寫程式隨機生成兩個,用vb語言編寫乙個程式,隨機生成兩個100 300之間的正整數,顯示他們,並求這兩個數的最大公約數
用VB,編寫程式,實現2,10,16進製制的轉換,不要太簡單的那種
用vb編寫程式將2019年到2019年之間的所有閏年顯
要求是用vb選擇結構編寫程式實現輸入值