domingo, 3 de noviembre de 2013

Programas

#1(Implementación de la condición if-then)

#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;
              }






#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;
}









 

No hay comentarios:

Publicar un comentario