From d3849299587675abf044981b43d01b3489ecb140 Mon Sep 17 00:00:00 2001 From: Ananya Singh <32653321+ananya1304@users.noreply.github.com> Date: Mon, 1 Oct 2018 23:10:11 +0530 Subject: [PATCH] Concatenate a string n times --- string_concatenate_n_times.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 string_concatenate_n_times.cpp diff --git a/string_concatenate_n_times.cpp b/string_concatenate_n_times.cpp new file mode 100644 index 0000000..4f90686 --- /dev/null +++ b/string_concatenate_n_times.cpp @@ -0,0 +1,21 @@ +#include +#include +using namespace std; + +string repeat(string s, int n) +{ + string s1 = s; + + for (int i=1; i