;又看到一题,没事时候来看看,哈哈;Give 7 numbers, range from 0-13. The number of 0 is uncertain, other numbers can appear only once. 0 can be converted to any number. Please check whether or not it contains 5 continuous numbers;;取到7个数,0可以重复,其他不重复,0可以充当任意数,判断7个数里面是否存在5个连续数;1,5,2,4,0,13,10 0->3 1,2,3,4,5,10,13 return true;1,5,2,0,0,13,10 0->3 0->4 1,2,3,4,5,10,13 return true;1,5,6,0,0,13,10 return false;这是我2006-9-8今天下午无聊向jailu要了一个题做一下,还是写了好久,过程有一些曲折,本来是要写随机数,结果没有写成;由图形界面改成控制台,再改成图形界面,反复搞了几次,时间上也浪费了很多;我这么说不是为了表示我写程序有多快,相反,我写程序很慢,相当地慢,现在马上想到有一个原因就是我写程序很抠;因为很抠导致我连增加一个变量4个字节都要思前想后地,;但最后还是写出来了,比较高兴,呵呵;但是程序还是很乱,因为是练手的程序嘛,有一些形式与格式的东西我没有太在意了;而且写这个程序的时候我也没有刻意去抠了,很方便的地方就尽量往方便里写了;OK,这个程序结束23:20 2006-9-8.586 .model flat,stdcall option casemap:none include windows.inc include user32.inc include kernel32.inc include shell32.incinclude masm32.incincludelib user32.lib includelib kernel32.lib includelib shell32.libincludelib masm32.libinclude C:masm32macrosMACROS.ASMDLG_MAIN equ 1000.datafmt_num db " %d ",0num7 dd 8 dup (0)fmt_mynum db "%d,%d,%d,%d,%d,%d,%d",0copyrights db "Triones 2006-9-8",10,0outinfo db "请输入7位数字(范围为0~13,不足7位默认为0,超出7位截止):",0yes db "数字连续:",0zero2 db "0->%d ",0LF db 10,0no db "数字不连续",0.data?hInstance dd ?hWinMain dd ?cout dd ?flag dd ?tmpstr db 128 dup (?)result db 128 dup (?).code_output proc @position,@flag pushad invoke lstrcpy,addr result,addr yes mov esi,flag mov ecx,@position shr esi,cl and esi,01fh xor ebx,ebx xor edi,edi .while ebx < 5 shr esi,1 jc @F mov eax,@position add eax,ebx mov edx,eax mov ecx,eax mov eax,1 shl eax,cl or flag,eax invoke wsprintf,addr tmpstr,addr zero2,edx invoke lstrcat,addr result,addr tmpstr @@: inc ebx .endw invoke lstrcat,addr result,addr LF mov ebx,1 mov esi,flag .while ebx < 14 mov esi,flag mov ecx,ebx shr esi,cl jnc @F dec ecx invoke wsprintf,addr tmpstr,addr fmt_num,ecx invoke lstrcat,addr result,addr tmpstr @@: inc ebx .endw invoke SetDlgItemText,hWinMain,4218,addr result popad ret_output endp_main proc pushad xor esi,esi mov flag,esi mov cout,esi mov ebx,4211 .while ebx <= 4217 invoke GetDlgItemInt,hWinMain,ebx,NULL,FALSE .if eax > 13 MsgBox hWinMain,"数字过大",NULL,MB_OK popad ret .endif .if eax == 0 inc cout .endif mov num7[esi],eax add esi,4 inc ebx .endw xor esi,esi .while esi < 1ch mov ecx,num7[esi] .if ecx != 0 mov eax,1 shl eax,cl xor eax,flag .if eax < flag MsgBox hWinMain,"数字有重复",NULL,MB_OK popad ret .endif mov flag,eax .endif add esi,4 .endw ;这里flag里就有数字记录了 mov ebx,1 .while ebx < 10 mov esi,flag mov ecx,ebx shr esi,cl and esi,01fh .if esi == 01fh invoke _output,ebx,0 popad ret .endif xor ecx,ecx xor edi,edi xor edx,edx .while ecx < 5 shr esi,1 jc @F inc edi @@: inc ecx .endw .if edi <= cout invoke _output,ebx,edi popad ret .endif inc ebx .endw invoke SetDlgItemText,hWinMain,4218,addr no popad ret_main endp_ProcDlgMain proc uses ebx edi esi hWnd,wMsg,wParam,lParam LOCAL @szBuffer[256]:byte mov eax,wMsg .if eax == WM_CLOSE invoke EndDialog,hWnd,NULL .elseif eax == WM_INITDIALOG push hWnd pop hWinMain .elseif eax == WM_COMMAND mov eax,wParam movzx eax,ax .if eax == IDOK invoke _main .endif .else mov eax,FALSE ret .endif mov eax,TRUE ret_ProcDlgMain endpstart: invoke GetModuleHandle,NULL mov hInstance,eax invoke DialogBoxParam,hInstance,DLG_MAIN,NULL,offset _ProcDlgMain,NULL invoke ExitProcess,NULL end start