Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
sort_using_pointers.c
//gcc 5.4.0 #include <stdio.h> int* sort(int *,int *); int main(void) { int arr[5] = {5,4,3,2,1}, n = 5; int *ptr; /* scanf("%d",&n); for (int i = 0; i < n; i++) scanf("%d",&arr[i]); */ ptr = sort(&arr[0],&n); for (int i = 1; i <= n; i++) printf("%d ",*(ptr+i)); return 0; } int* sort(int *a,int *n) { int temp = 0; for (int i = 0; i < *n; i++) { for( int j = 0; j < *n; j++) { if (*(a+j) > *(a+j+1)) { temp = *(a+j); *(a+j) = *(a+j+1); *(a+j+1) = temp; } } } return a; }
run
|
edit
|
history
|
help
0
T3.C
Homework 2 Code
Spring 2017 Lab 4 v1.1
Character testing
C_141204_ConcatenarCadenas
Struct
Michael Bean's Spring 2017 Lab 3 v1
mohan
Ppp
No Pyramid toggle