From 99cd8fbd0eaef3dc2de43f96f1d97d896ef31be9 Mon Sep 17 00:00:00 2001 From: Saasha Joshi <32019413+SaashaJoshi@users.noreply.github.com> Date: Thu, 4 Oct 2018 10:41:01 +0530 Subject: [PATCH 1/2] bubble_sort.cpp: Optimize the C++ code Replaced use of stdio.h by much safer iostream header file Replaced printf statements by std::cout statements. Closes https://github.com/NITSkmOS/Algorithms/issues/240 --- bubble_sort/Cpp/bubble_sort.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/bubble_sort/Cpp/bubble_sort.cpp b/bubble_sort/Cpp/bubble_sort.cpp index 7afbf06d..44f9a352 100644 --- a/bubble_sort/Cpp/bubble_sort.cpp +++ b/bubble_sort/Cpp/bubble_sort.cpp @@ -1,4 +1,5 @@ -#include +#include +using namespace std; void swap(int *xp, int *yp) { int temp = *xp; @@ -17,8 +18,6 @@ void bubble_sort(int arr[], int n) { swapped = true; } } - - // If no two elements were swapped by inner loop, then break if (swapped == false) break; } @@ -28,9 +27,8 @@ void bubble_sort(int arr[], int n) { void print_array(int arr[], int size) { int i; for (i = 0; i < size; i++) - printf("%d ", arr[i]); - - printf("\n"); + cout << arr[i] << " "; + cout << endl; } // Driver program to test above functions @@ -38,7 +36,7 @@ int main() { int arr[] = {64, 34, 25, 12, 22, 11, 90}; int n = sizeof(arr) / sizeof(arr[0]); bubble_sort(arr, n); - printf("Sorted array: \n"); + cout << "Sorted array: " << endl; print_array(arr, n); return 0; } From f298c7655e42920c40a0e7809a7fcb8e09b4c476 Mon Sep 17 00:00:00 2001 From: Paawan Mukker Date: Thu, 4 Oct 2018 02:05:48 +0530 Subject: [PATCH 2/2] README.md: Remove codacy badge, Add travis badge This removes Codacy badge and adds Travis badge to README.md file. Closes https://github.com/NITSkmOS/Algorithms/issues/209 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bedd8b06..1c0d18cc 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Gitter](https://badges.gitter.im/NITSkmOS/algo.svg)](https://gitter.im/NITSkmOS/algo?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![NITSkmOS Algorithms](https://img.shields.io/badge/NITSkmOS-Algorithms-blue.svg)](https://github.com/NITSkmOS/Algorithms) -[![Codacy Badge](https://api.codacy.com/project/badge/Grade/29024673e94b48459809432cdd280e39)](https://app.codacy.com/app/NITSkmOS/Algorithms?utm_source=github.com&utm_medium=referral&utm_content=NITSkmOS/Algorithms&utm_campaign=Badge_Grade_Settings) +[![Build Status](https://travis-ci.com/NITSkmOS/Algorithms.svg?branch=master)](https://travis-ci.com/NITSkmOS/Algorithms) [![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/NITSkmOS/Algorithms/blob/master/LICENSE)