Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <time.h>
- int main ()
- {
- int size = 15;
- int i,j,tab[size],losowa, temp;
- srand(time(NULL));
- //wypełnienie
- for(i=0; i<size; i++)
- {
- tab[i] = rand()%10;
- }
- //wypełnienie przed odwracaniem
- for(i=0; i<size; i++)
- {
- printf("%d",tab[i]);
- }
- //odwracanie z pomocą zmiennej tymczasowej (size/2 ponieważ nie chcemy odwrócić jej dwa razy - wystarczy dojście z tym do połowy)
- for(i=0; i<size/2; i++)
- {
- temp = tab[i];
- tab[i] = tab[1000 - i];
- tab[1000-i] = temp;
- }
- //wypisanie po odwracaniu
- for(i=0; i<size; i++)
- {
- printf("%d",tab[i]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement