diff --git a/Contributors.md b/Contributors.md index 7684c46..cf048f4 100644 --- a/Contributors.md +++ b/Contributors.md @@ -24,3 +24,4 @@ Welcome to the list of people who contributed to this repo 💥 7. [Ayansh](https://github.com/badasschef) 8. [Deep](https://github.com/deep846) 9. [Amit](https://github.com/amitShindeGit) +10. [Leonard Rizta Anugerah Perdana](https://github.com/leonardrizta) \ No newline at end of file diff --git a/Searching and Sorting/Bubble Sort/C++/bubble_sort.cpp b/Searching and Sorting/Bubble Sort/C++/bubble_sort.cpp new file mode 100644 index 0000000..4524f71 --- /dev/null +++ b/Searching and Sorting/Bubble Sort/C++/bubble_sort.cpp @@ -0,0 +1,35 @@ +#include +using namespace std; + +void swaping(int *a, int *b) +{ + int temp = *a; + *a=*b; + *b=temp; +} + +void sorting(int arr[], int arrsize) +{ + for(int i=arrsize-1;i>0;i--){ + for(int j=0;jarr[j+1]){ + swaping(&arr[j],&arr[j+1]); + } + } + } +} + +int main() +{ + int n; + cin>>n; + int arr[n]; + int arrsize = sizeof(arr)/sizeof(arr[0]); + for(int i=0;i>arr[i]; + } + sorting(arr,arrsize); + for(int i=0;i