![]() |
|
論壇說明 |
歡迎您來到『史萊姆論壇』 ^___^ 您目前正以訪客的身份瀏覽本論壇,訪客所擁有的權限將受到限制,您可以瀏覽本論壇大部份的版區與文章,但您將無法參與任何討論或是使用私人訊息與其他會員交流。若您希望擁有完整的使用權限,請註冊成為我們的一份子,註冊的程序十分簡單、快速,而且最重要的是--註冊是完全免費的! 請點擊這裡:『註冊成為我們的一份子!』 |
![]() ![]() |
|
主題工具 | 顯示模式 |
![]() |
#1 |
註冊會員
|
![]() 大家好~~
我所使用的組合語言軟體是 masm615 問題是,我想要用組合語言寫出不重複亂數,我有用C寫出來,但是組合不會寫 但是去 不知道錯誤在那裡,請高手們 幫幫忙寫出來,若可以的話,請順手注解意思 謝謝~~~ INCLUDE Irvine32.inc .data a DWORD 10 dup(0) count dword 1 x dword 0 y dword 0 str1 byte "success",13,10,0 .code main PROC call clrscr mov esi,offset a call randomize .while (x<10) mov eax,10 call randomrange mov esi,offset a .while(count == 1) mov y,0 .while(y<10) .if([esi]==eax) mov count,1 mov esi,offset a mov eax,10 call randomrange .else add esi,4 mov count,0 .endif add y,1 .endw ;while inside .endw mov [esi],eax add esi,4 call writeint inc x .endw exit main ENDP END main 我學習過 用 DEC C++ 寫 C程式 #include <stdio.h> #include <stdlib.h> #include <time.h> #define max 10 int HasAppear(int a[max],int);/*檢查已出現的數值*/ void ShowArray(int a[max]);/*顯示陣列*/ //=================================== int main(void) { int i,j; int card[max]={0}; int temp;/*作為 暫存亂數 的 元素*/ srand(time(NULL)); for(i=0;i<max;i++) { temp=rand()%max + 1; /*產生亂數*/ while(HasAppear(card, temp) == 1)/*呼叫副程式比較是否曾經出現*/ { temp=rand()%max +1;/*曾經出現,再重新產生亂數*/ } card[i]=temp;/*暫存元素 存入 陣列內*/ } ShowArray(card); system("Pause"); return 0; } //====================================================== int HasAppear(int a[max], int temp) { int i,j; for(i=0;i<max;i++) { if(a[i]==temp) return 1;/*跑陣列,01234這樣慢慢的比較整個回圈,相同的就回傳true*/ } return 0;/*沒有相同的就 回傳 false*/ } //======================================================= void ShowArray(int a[]) { int i,j; for(i=0;i<max;i++) { printf("%2d", a[i]); printf("\n"); } } |
![]() |
送花文章: 0,
![]() |
![]() ![]() |
|
|
![]() |
||||
主題 | 主題作者 | 討論區 | 回覆 | 最後發表 |
程式 - 組合語言問題 | Shecil | 程式語言討論區 | 0 | 2010-10-18 09:18 PM |
程式 - 關於組合語言問題 | leowang | 程式語言討論區 | 7 | 2006-10-31 04:52 PM |