All pastes #793898 Raw Edit

Anonymous

public cpp v1 · immutable
·published 2007-11-22 18:50 UTC
rendered paste body
#include <iostream>#include <cmath>using namespace std;bool es_primer(int n){    if(n <= 1) return false;    int arr_n = int(sqrt(n));    for(int i = 2; i <= arr_n; ++i) {        if(n % i == 0) return false;    }    return true;}int main() {    int primos[20]={1,2,3,4,5,6,7,3,4,5,5,7,9,11,2,3,5,6,7,3};    //suponiendo q el vector tiene numeros enteros en todas las posiciones, scribe     //un programa q determine el numero maximo de numeros primos seguidos q aparecen en el vector        int c = 0; //contador    int r = 0; // record    for (int i = 0; i < 20; ++i) {        if (es_primer(primos[i])){            ++c;            if (c > r) r = c;        } else c = 0;            }    cout << r << endl;}