另外我不会汇编,手头也找不到 VS 但是我按照题目想了想思路大概是这样求指点… @
yangqi#include <stdio.h>
#include <stdlib.h>
int main (void)
{
char get1[] = "Please input an integer:";
char get2[]="posamount:";
char get3[]="negamount:";
char get4[]="input n: ";
char format[] = "%d";
char format2[] = "%s%d\n";
int input;
asm{
xor ebx, ebx
xor ecx, ecx
lea eax, get4
push eax
call printf
add esp, 4
lea eax, input
push eax
lea eax, format
push eax
call scanf
add esp,8
mov edx, input
loop:
cmp edx, 0
jng endloop
lea eax, get1
push eax
call printf
add esp, 4
lea eax,input
push eax
lea eax,format
push eax
call scanf
add esp,8
mov eax,input
cmp eax,0
jg positive
je loop
inc ecx
jmp loop
positive:
inc ebx
jmp loop
endloop:
push ebx
lea eax, get2
push eax
lea eax, format2
push eax
call printf
add esp, 12
push ecx
lea eax, get3
push eax
lea eax, format2
push eax
call printf
add esp, 12
}
return 0;
}