Implementación de la condición if-them
1. se pretende realizar un programa en lenguaje ensamblador equivalente al sig. código en C:
#include <iostream.h>
main()
{
int a[] = {12, 5, 34, 75, 10, 25};int n = 6;
int max, i;
for (max = i = 0; i < n; i++)
if (a[i] > max)
max = a[i];
cout << max << end1;
}
2. Implementación de la condición if-then-else. Se pretende realizar un programa en lenguaje ensamblador equivalente al siguiente código en C:
Código:
#include <iostream.h>
main()
{
int a[] = {-12, 5, -34, -75, -10, 25};
int n = 6;
int max, i;
int npos, nneg;
for (i = npos = nneg = 0; i < n; i++)
if (a[i] > 0)
npos++;
else
nneg++;
cout << “+: “ << npos << “; -: “ << nneg << end1;
main()
{
int a[] = {-12, 5, -34, -75, -10, 25};
int n = 6;
int max, i;
int npos, nneg;
for (i = npos = nneg = 0; i < n; i++)
if (a[i] > 0)
npos++;
else
nneg++;
cout << “+: “ << npos << “; -: “ << nneg << end1;
}
No hay comentarios:
Publicar un comentario