Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctype.h>
- #include <string.h>
- void funkcija(int n, int * niza) {
- int x = niza[0];
- int nova_niza[n];
- nova_niza[0] = x;
- int j = 1;
- for(int i = 1; i < n; i++) {
- if(x < niza[i]) {
- nova_niza[j] = niza[i];
- j++;
- x = niza[i];
- }
- else {
- if((x + 1) < niza[i] * 2) {
- x++;
- nova_niza[j] = x;
- j++;
- }
- }
- }
- for(int i = 0; i < j; i++) {
- printf("%d ", nova_niza[i]);
- }
- }
- int main(int argc, const char * argv[]) {
- int n;
- scanf("%d", &n);
- int niza[n];
- for(int i =0 ; i < n; i++) {
- scanf("%d", &niza[i]);
- }
- funkcija(n, niza);
- }
- /*
- 1 7 6 10 11 15 20 6 -2 14
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement