Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(){
- int a[50],i,j,randomBroj=1,n,zadnjiParni,temp;
- for(i=0;randomBroj!=0;i++){
- randomBroj=rand()%11;
- a[i]=randomBroj;
- }
- n=i;
- for(i=n-2;a[i]%2==1;i--);
- zadnjiParni=i;
- for(i=0;i<n;i++)
- printf("%d ", a[i]);
- printf("\n");
- for(i=n-1;i>=zadnjiParni;i--)
- {
- a[i+1]=a[i];
- }
- a[zadnjiParni]=0;
- n++;
- for(i=0;i<n;i++)
- printf("%d ", a[i]);
- printf("\n");
- for(i=0;i<n;i++)
- for(j=i;j<n;j++)
- if(a[i]>a[j]&&j!=zadnjiParni&&i!=zadnjiParni)
- {
- temp=a[j];
- a[j]=a[i];
- a[i]=temp;
- }
- for(i=0;i<n;i++)
- printf("%d ", a[i]);
- printf("\nIndeks zadnjeg parnog je %d",zadnjiParni+1);
- //rand()%11;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement