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(niza[i] < 0) {
- }
- else {
- 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);
- }
- /*
- 14 12 -6 20 15 -1 10 6 -7 -20
- 14, 12, -6, -7, -8, -9, -10, -20
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement