Advertisement
Aveneid

Untitled

Dec 5th, 2017
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     int T[]={9,8,7,6,5,4,3,2,1,0}; //zmien tabliice
  7.     int x;
  8.     for(x=0;x<(sizeof(T)/sizeof(int));x++){
  9.         printf("%d ", T[x]);
  10.     }
  11.     podprogram(&T,sizeof(T));
  12.     printf("\n\n");
  13.  
  14.     for(x=0;x<(sizeof(T)/sizeof(int));x++){
  15.         printf("%d ", T[x]);
  16.     }
  17.     return 0;
  18. }
  19. void swapS(int *a, int *b){
  20.     int tmp = *b;
  21.     *b=*a;
  22.     *a=tmp;
  23. }
  24. void podprogram(int t[],int size){
  25.     if(size%2==1)
  26.         size-=1;
  27.     int x;
  28.     for(x=0;x<size-1;x=x+2){
  29.         if(t[x]>t[x+1]){
  30.             swapS(&t[x],&t[x+1]);
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement