Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
selection sort
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
#include<stdio.h> #include<string.h> void swap(int *x,int *y) { int temp; temp=*x; *x=*y; *y=temp; } void selsort(int arr[],int n) { int i,j,min_index; for(i=0;i<n-1;i++) { min_index=i; for(j=i+1;j<n;j++) if(arr[j]<arr[min_index]) //j=min_index; min_index=j; swap(&arr[min_index],&arr[i]) ; } } void print(int arr[],int size) { int i; for(i=0;i<size;i++) printf("%d\n",arr[i]); } main() { int arr[]={78,90,23,9,40,11,56}; int n; n=sizeof(arr)/sizeof(arr[0]); selsort(arr,n); printf("sorted array\n"); print(arr,n); }
gcc
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
edit mode
|
history
|
discussion