Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int n,i,*x,tymczasowa;
- int main()
- {
- //Zadanie 4 Zmienić kolejność elementów w tablicy na odwrót.
- printf("Podaj Ilosc elementow tablicy ktore chcesz: ");
- scanf("%d",&n);
- x = (int*) malloc (n+1 * sizeof(int));
- for(i=0;i<n;i++)
- {
- printf("%d element tablicy to : ",i+1); scanf("%d",&x[i+1]);
- }
- for(int i=1;i<=n/2;i++)
- {
- tymczasowa=x[i];
- x[i]=x[n-i];
- x[n-i]=tymczasowa;
- }
- /// temp=a
- /// a=b
- /// b=temp
- for(int i=0;i<n;i++)
- printf("%d ",x[i+1]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement