#include<stdio.h>
#include<conio.h>
void showElements(int arr[],int n){
int i;
if(n==0)
printf("[]");
else if(n>0)
printf("[");
for(i=0;i<n;i++){
if(i==n-1){
printf("%d",arr[i]);
printf("]");
}else
printf("%d,",arr[i]);
}
}
void sortData(int arr[],int n){
int i,j,temp;
for(i=0;i<n-1;i++){
for(j=i+1;j<n;j++){
if(arr[i]>arr[j]){
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
}
int getLength(int arr[]){
int i=0;
while(arr[i]!='\0'){
i++;
}
return i;
}
void main(){
int arr[]={2,1,3,4,9,8,7,6,5};
int i,j,len;
clrscr();
len=getLength(arr);
printf("\n Before Sorting Array Elements \n");
showElements(arr,len);
sortData(arr,len);
printf("\n After Sorting Array Elements \n");
showElements(arr,len);
getch();
}
Thursday, April 28, 2016
Selection Sort
Subscribe to:
Post Comments (Atom)
Spring Boot 3 : JWT with SecurityFilterChain, AuthorizeHttpRequests, RequestMatchers
pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0...
-
Installation of MongoDB The executable file needs to be downloaded from: https://www.mongodb.com/download-center?jmp=nav#communit...
-
Form to add multiple rows: <! DOCTYPE html> <%@ page language = "java" contentType = "text/html; cha...
No comments:
Post a Comment