Ver Mensaje Individual
  #4 (permalink)  
Antiguo 09/02/2013, 17:27
amchacon
 
Fecha de Ingreso: julio-2012
Mensajes: 375
Antigüedad: 11 años, 9 meses
Puntos: 28
Respuesta: Problema en c++ primos

No se debe, pero por esta vez te voy ha hacer el trabajo sucio:

Código:
#include <iostream>
using namespace std;
int main()
{
    int matriz [] = {5,4,3,7,8},i,j;
    bool Primo;

    cout<<"Los numeros primos son: "<<endl;

    for (i=0; i<5; i++)
    {
        Primo = true;
        for(j=2; j<matriz[i]; j++) 
        {
            if(matriz[i]%j==0)
            {
                Primo = false;
                j = matriz[i];
            }
        }
        if (Primo == true)
            cout<<matriz[i]<<" ";
    }

    cin.get();
    return 0;
}
El algoritmo es bastante sencillo pero pregunta si tienes dudas.