Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
IndiSelSort
//gcc 7.4.0 //indirect selection sort (using pointer function) //this code is created by Rezaul Hoque on August 09,2021;contact: jewelmrh@yahoo.com //note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; #include <stdio.h> #include <stdlib.h> int min(int [],int [],int,int); void sel(int (*)(), int [],int [],int,int); int min(int a[], int index[],int n,int l) {int min,loc; min=a[index[l]]; loc=l; for(int j=l+1;j<=n-1;j++) if(min>a[index[j]]){ min=a[index [j]]; loc=j; } return(loc); } void sel(int (*pf)(),int a[],int index[],int n,int l){ int loc; for(l=0;l<10;l++) { loc=(*pf)(a,index,10,l); int temp=index[l]; index[l]=index[loc]; index[loc]=temp; } for(l=0;l<10;l++) printf("%d\n",a[index[l]]); } int main() { int l; int a[]={23,40,83,90,55,66,82,91,10,51}; int index[]={0,1,2,3,4,5,6,7,8,9}; printf("\nOriginal array:\n"); for(int l=0;l<10;l++) printf("%d\n",*(a+l)); printf("\n"); printf("After indirect selection sort:\n"); sel(min,a,index,10,l); printf("\n"); printf("Original array:\n"); for(int l=0;l<10;l++) printf("%d\n",*(a+l)); }
run
|
edit
|
history
|
help
0
swapping using call by reference
a
Timestamp microsecond for C
SAI_1-3.c
Volume of a square pyramid With functions
HW2A
bitwise operations
TopRightTriangle.c
Stub Program for Problem 2 HW 2
qsort