Program moving values in vectors... need help.
I have written a program that, should move values of a given vector, but id does nothing after declarating for how many places move te values. If you could check the code and write whatis wrong, i would be grateful.
Code:
#include <stdio.h>
#include <stdlib.h>
int przesun(int t[], int p);
void main()
{
int k;
int w[10];
printf ("Define, how many places you want to move values: ");
scanf ("%d\n",&k);
przesun (w,k);
}
int przesun (int t[], int p)
{
int i;
for (i=0 ; i<10 ; i++)
{
t[i]=rand();
printf("%d-th element of array is equal %d\n",i,t[i]);
}
for (i=9 ; i>=0 ; i--)
{
t[i]=t[i-p];
printf("&d-th after moving for %d places is equal %d\n",i,p,t[i]);
if(i-p<0)
{
t[i]=t['0'];
}
}
return 0;
}