Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <ctype.h>
- #include <math.h>
- int funkcija(int *niza, int n) {
- int i = 0;
- int sum = 0;
- while(i < n) {
- if(niza[i] == 0 || niza[i] == 1) {
- sum += niza[i];
- i++;
- }
- else {
- sum += niza[i];
- i += (niza[i] / 2);
- }
- }
- return sum;
- }
- 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]);
- }
- int result = funkcija(niza, n);
- printf("%d\n", result);
- }
- /*
- 10
- 2 0 3 1 4 5 6 2 10 11
- **/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement