Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- int eprost(int broj) {
- int broj_na_deliteli = 0;
- for(int i = 1; i <= broj; i++) {
- if(broj % 2 == 0) {
- broj_na_deliteli++;
- }
- }
- if(broj_na_deliteli > 2) {
- return 0;
- }
- else {
- return 1;
- }
- }
- int rekurzija(int *niza, int n, int i) {
- if(i >= n) {
- return 1;
- }
- if(eprost(niza[i])) {
- return rekurzija(niza, n, i + 2);
- }
- else {
- return 0;
- }
- }
- int main(int argc, char * argv[])
- {
- int n;
- scanf("%d", &n);
- int niza[n];
- for(int i = 0; i < n; i++) {
- scanf("%d", &niza[i]);
- }
- printf("%d\n", rekurzija(niza, n, 0));
- return 0;
- }
- /*
- 6 8
- 1 2 3 4 5 6 7 8
- 2 1 2 3 4 5 6 7
- 3 4 5 6 7 8 9 10
- 4 5 6 7 8 9 10 0
- 5 6 7 8 9 10 0 1
- 6 7 8 9 10 0 1 2
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement