Advertisement
KvArt

Izbacivanje elementa niza uz pomoc indeksa

Aug 14th, 2022
717
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. #include <stdio.h>
  2. #define N 100
  3.  
  4. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  5.  
  6. void main()
  7. {
  8.     while(1)
  9.         {
  10.             int n,i;
  11.             printf("Unesite duzinu niza n: "); scanf("%d",&n);
  12.             if (n<=0 || n>N) break;
  13.             printf("Unesite elemente niza: "); int a[N];
  14.             for(i=0;i<n; scanf("%d",&a[i++]));
  15.             printf("Unesite poziciju elementa za izbacivanje: "); int p; scanf("%d",&p);
  16.             for(i=p+1; i<n; i++) a[i-1]=a[i];
  17.             n--;
  18.             printf("Niz nakon obrade izgleda ovako: "); for(i=0; i<n; printf("%d ",a[i++]));
  19.             printf("\n\n");
  20.         }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement