From f59a1d406f1690fbf91dd32e6beb2841c6754838 Mon Sep 17 00:00:00 2001 From: Senbagaraman Date: Mon, 19 Oct 2020 22:35:38 +0530 Subject: [PATCH 1/3] Added day2 codes #35 --- Day2/C#/StringReverse.cs | 31 ++++++++++++++++++++++++++++++ Day2/C#/palindrome.cs | 41 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 Day2/C#/StringReverse.cs create mode 100644 Day2/C#/palindrome.cs diff --git a/Day2/C#/StringReverse.cs b/Day2/C#/StringReverse.cs new file mode 100644 index 00000000..da6fbb58 --- /dev/null +++ b/Day2/C#/StringReverse.cs @@ -0,0 +1,31 @@ +/** + * + * @author: Senbagaraman Manoharan + * @date: 19th October 2020 + * + * Given a string, write a program to return a new string with reversed order of characters + * + * */ +using System; +using System.Collections.Generic; +using System.Reflection; + +public class Program +{ + + public static void Main() + { + string enteredString, rvrString = ""; + int stringLength; + Console.Write("The string to be reversed: "); + enteredString = Console.ReadLine(); + stringLength = enteredString.Length - 1; + while (stringLength >= 0) + { + rvrString = rvrString + enteredString[Length]; + stringLength--; + } + Console.WriteLine("The reversed string is {0}", rvrString); + Console.ReadLine(); + } +} \ No newline at end of file diff --git a/Day2/C#/palindrome.cs b/Day2/C#/palindrome.cs new file mode 100644 index 00000000..3124b84b --- /dev/null +++ b/Day2/C#/palindrome.cs @@ -0,0 +1,41 @@ +/** + * + * @author: Senbagaraman Manoharan + * @date: 19th October 2020 + * + * Given a string, write a funcation which prints whether the given string is palindrome or nor + * + * */ +using System; +using System.Collections.Generic; +using System.Reflection; + +public class Program +{ + + public static void Main() + { + string enteredString, rvrString = ""; + int stringLength; + Console.Write("The string to be checked: "); + enteredString = Console.ReadLine(); + stringLength = enteredString.Length - 1; + while (stringLength >= 0) + { + rvrString = rvrString + enteredString[Length]; + stringLength--; + } + Console.WriteLine("The reversed string is {0}", rvrString); + + if(enteredString.Equals(rvrString)) + { + Console.WriteLine("The given string is palindrome"); + } + else + { + Console.WriteLine("The given string is not palindrome"); + } + + Console.ReadLine(); + } +} \ No newline at end of file From ad80390bba47ce25de54d300583f2fab051a02f4 Mon Sep 17 00:00:00 2001 From: Senbagaraman Manoharan Date: Mon, 19 Oct 2020 22:40:35 +0530 Subject: [PATCH 2/3] Added the solutions for Day 2 #35 --- Day2/README.md | 90 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 89 insertions(+), 1 deletion(-) diff --git a/Day2/README.md b/Day2/README.md index c0743faf..b5b8df9d 100644 --- a/Day2/README.md +++ b/Day2/README.md @@ -515,7 +515,7 @@ void main(){ ### [reverse.rb](./Ruby/reverse.rb) -```ruby +```c# =begin @author: aaditkamat @date: 22/12/2018 @@ -555,6 +555,47 @@ def long_solution_recursive(str) end ``` + + +## C# Implementation + +### [StringReverse.cs](./C#/StringReverse.cs) + +```c# +/** + * + * @author: Senbagaraman Manoharan + * @date: 19th October 2020 + * + * Given a string, write a program to return a new string with reversed order of characters + * + * */ +using System; +using System.Collections.Generic; +using System.Reflection; + +public class Program +{ + + public static void Main() + { + string enteredString, rvrString = ""; + int stringLength; + Console.Write("The string to be reversed: "); + enteredString = Console.ReadLine(); + stringLength = enteredString.Length - 1; + while (stringLength >= 0) + { + rvrString = rvrString + enteredString[Length]; + stringLength--; + } + Console.WriteLine("The reversed string is {0}", rvrString); + Console.ReadLine(); + } +} +``` + +
## Part B -- Palindrome Check @@ -981,6 +1022,53 @@ public class StringReverseAndPalin { } ``` +## C# implementation + +### [palindrome.cs](./C#/palindrome.cs) +```C# +/** + * + * @author: Senbagaraman Manoharan + * @date: 19th October 2020 + * + * Given a string, write a funcation which prints whether the given string is palindrome or nor + * + * */ +using System; +using System.Collections.Generic; +using System.Reflection; + +public class Program +{ + + public static void Main() + { + string enteredString, rvrString = ""; + int stringLength; + Console.Write("The string to be checked: "); + enteredString = Console.ReadLine(); + stringLength = enteredString.Length - 1; + while (stringLength >= 0) + { + rvrString = rvrString + enteredString[Length]; + stringLength--; + } + Console.WriteLine("The reversed string is {0}", rvrString); + + if(enteredString.Equals(rvrString)) + { + Console.WriteLine("The given string is palindrome"); + } + else + { + Console.WriteLine("The given string is not palindrome"); + } + + Console.ReadLine(); + } +} +``` + ### Have Another solution? The beauty of programming lies in the fact that there is never a single solution to any problem. From a0e3750199a73144f666be0eff5934c551a60a5d Mon Sep 17 00:00:00 2001 From: Senbagaraman Date: Mon, 19 Oct 2020 22:48:17 +0530 Subject: [PATCH 3/3] #35 updated contributions --- CONTRIBUTORS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 39699d08..983101ee 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -49,6 +49,8 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
GAURAV KUMAR

📖 💻
wboccard

📖 💻
d-l-mcbride

📖 💻 +
Senbagaraman

📖 💻 +