Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions C++ STL/Binary Search using STL.cpp.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <algorithm>
#include <iostream>
using namespace std;

void show(int a[], int arraysize)
{
for (int i = 0; i < arraysize; ++i)
cout << a[i] << " ";
}

int main()
{
int a[] = { 2, 5, 12, 7, 24, 8, 1, 43, 10, 0 };
int asize = sizeof(a) / sizeof(a[0]);

sort(a, a + asize);

if (binary_search(a, a + 10, 8))
cout << "\nElement found in the array";
else
cout << "\nElement not found in the array";

if (binary_search(a, a + 10, 10))
cout << "\nElement found in the array";
else
cout << "\nElement not found in the array";

return 0;
}
16 changes: 16 additions & 0 deletions C++ STL/Sort using STL.cpp.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <bits/stdc++.h>
using namespace std;

int main()
{
int arr[] = {1, 5, 8, 9, 6, 7, 3, 4, 2, 0};
int n = sizeof(arr)/sizeof(arr[0]);

sort(arr, arr+n);

cout << "Sorted Array is : ";
for (int i = 0; i < n; ++i)
cout << arr[i] << " ";

return 0;
}