Advertisement
Gleeshoux

c kod

Nov 18th, 2023
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.70 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(){
  4. int a[50],i,j,randomBroj=1,n,zadnjiParni,temp;
  5. for(i=0;randomBroj!=0;i++){
  6.     randomBroj=rand()%11;
  7.     a[i]=randomBroj;
  8.  
  9.  
  10. }
  11. n=i;
  12.  
  13. for(i=n-2;a[i]%2==1;i--);
  14. zadnjiParni=i;
  15. for(i=0;i<n;i++)
  16.     printf("%d ", a[i]);
  17. printf("\n");
  18.  
  19. for(i=n-1;i>=zadnjiParni;i--)
  20. {
  21.     a[i+1]=a[i];
  22.  
  23. }
  24.    a[zadnjiParni]=0;
  25.    n++;
  26. for(i=0;i<n;i++)
  27.     printf("%d ", a[i]);
  28. printf("\n");
  29.  
  30. for(i=0;i<n;i++)
  31.     for(j=i;j<n;j++)
  32.         if(a[i]>a[j]&&j!=zadnjiParni&&i!=zadnjiParni)
  33. {
  34.     temp=a[j];
  35.     a[j]=a[i];
  36.     a[i]=temp;
  37.  
  38. }
  39. for(i=0;i<n;i++)
  40.     printf("%d ", a[i]);
  41. printf("\nIndeks zadnjeg parnog je %d",zadnjiParni+1);
  42.  
  43.  
  44. //rand()%11;
  45.  
  46. return 0;
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement