已知10个分布在0至100内的正整数,统计大于等于60的数的个数和小于60的数的个数
C语言描述该程序流程:
#include <stdio.h>
int main()
{
int arr1[]={11,33,73,52,93,84,67,56,64,75};
int num1=0;
for(int i=1;i<10;i++)
{
if(arr1[i]>=60)
{
num1++;
}
}
printf("%d %d",num1,10-num1);
}
汇编语言:
include irvine32.inc
.data
numbers dword 11,33,73,52,93,84,67,56,64,75
count60 dword 0
count dword 10 ;对比10次
.code
main proc
mov esi,offset numbers
func:
cmp count,0
jz output
mov ebx,[esi]
cmp ebx,60
jge countadd ;大于等于60,则跳转
dec count
add esi,4
jmp func
countadd:
inc count60 ;数量加一
dec count
add esi,4
jmp func
output:
mov eax,count60
call writeint
mov ebx,eax
mov eax,10
sub eax,ebx
call writeint
main endp
end main
运行结果: