|
#include "StdAfx.h"
#include "Employee.h"
#ifdef __cplusplus // If used by C++ code,
extern "C" { // we need to export the C interface
#endif
IMPEXP void BubbleSort(int arr[], int n) {
bool swapped = true;
int j = 0;
int tmp;
while (swapped) {
swapped = false;
j++;
for (int i = 0; i < n - j; i++) {
if (arr[i] > arr[i + 1]) {
tmp = arr[i];
arr[i] = arr[i + 1];
arr[i + 1] = tmp;
swapped = true;
}
}
}
}
IMPEXP void Display(int arr[], int n) {
for(int i=0;i<n;i++)
printf("%d ",arr[i]);
printf("\n");
}
IMPEXP int BinarySearch(int arr[], int value, int left, int right) {
printf("\nSearch using BinarySearch...\n");
while (left <= right) {
int middle = (left + right) / 2;
if (arr[middle] == value)
return middle;
else if (arr[middle] > value)
right = middle - 1;
else
left = middle + 1;
}
return -1;
}
IMPEXP int LinearSearch(int arr[], int value, int left, int right) {
printf("\nSearch using LinearSearch...\n");
for(int i=left;i<right;i++)
{
if(arr[i]==value)
return i;
}
return -1;
}
IMPEXP int arr[]={1,9,8,4,6,5,3,7,2};
IMPEXP int searchval = 6;
IMPEXP int nSize = 9;
static void (*FPBubbleSort)(int arr[], int) = &BubbleSort;
static void (*FPDisplay)(int arr[], int) = &Display;
IMPEXP void InitBubbleSort( void )
{
printf("\nDisplay before BubbleSort...\n");
if(FPDisplay)
(*FPDisplay)(arr,nSize);
if(FPBubbleSort)
(*FPBubbleSort)(arr,nSize);
printf("\nDisplay after BubbleSort...\n");
if(FPDisplay)
(*FPDisplay)(arr,nSize);
}
#ifdef __cplusplus
}
#endif
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Selvam has worked on several technologies like Java, Python, Big data, VC++, MFC, Windows API and Weblogic server. He takes a lot of interest in reading technical articles and enjoys writing them too. He has been awarded as a Microsoft Community Star in 2004, MVP in 2005-06, SCJP 5.0 in 2009, Microsoft Community Contributor(MCC) 2011.
Big Data
o Google Professional Data Engineer 2021
o Confluent Certified Developer for Apache Kafka 2020
o Datastax Apache Cassandra 3.x Developer Associate Certification 2020
✓ Cloud
o Google Professional Cloud Architect 2021
o Microsoft Certified: Azure Solutions Architect Expert 2020
o AWS Certified Solutions Architect - Associate 2020
✓ Oracle Certified Master, Java EE 6 Enterprise Architect (OCMEA) 2018
Github :
https://github.com/selvamselvam
Web site:
http://www.careerdrill.com
Linkedin:
https://www.linkedin.com/in/selvamselvam/