Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- int mat[3][3] = {{7,9,12},{3,4,8},{13,7,9}};
- bool primo(int x)
- {
- for(int i = 2; i < x; ++i)
- if (!(x%i))
- return false;
- return true;
- }
- int calcola_prossimo_primo(int x)
- {
- while(!primo(++x));
- return x;
- }
- int maxRiga(int indice)
- {
- if (indice < 0 || indice > 3)
- return -1;
- int maggiore = 0;
- for(int i = 0; i < 3; ++i)
- {
- int tmp = calcola_prossimo_primo(mat[indice][i]);
- if (maggiore < tmp)
- maggiore = tmp;
- }
- return maggiore;
- }
- int main()
- {
- printf("%i\n", maxRiga(0));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement