From cff1bc31ece79cfa5a54be2ebacaa678ace83597 Mon Sep 17 00:00:00 2001 From: Tatiparthi Chenchu Jahnavi <85797034+Jahnavi998@users.noreply.github.com> Date: Sun, 13 Oct 2024 19:30:04 +0530 Subject: [PATCH 1/4] Create reverse.cs written logic to reverse a string --- Algorithms/Strings/reverse.cs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Algorithms/Strings/reverse.cs diff --git a/Algorithms/Strings/reverse.cs b/Algorithms/Strings/reverse.cs new file mode 100644 index 00000000..d4488ed4 --- /dev/null +++ b/Algorithms/Strings/reverse.cs @@ -0,0 +1,34 @@ +using System; + +namespace Algorithms.Strings; + +public static class ReversedString +{ + //comment + // In this Main Method we are taking the input and calling ReverseString Method which will return reversedString and we will print in main Method + //comment + public static void Main(string[] args) + { + // Sample Input : "reverse" + // Sample Output : "esrever" + string input= Console.ReadLine(); + string reversedString = ReverseString(input.Trim()); + Console.WriteLine(reversedString); + } + + //comment + // This Method will take input as string and return the reversed string + //comment + + public static string ReverseString (string input) + { + string reverseString=""; + int length = input.Length; + while(length!=0) + { + reverseString= reverseString+input[length-1]; + length-=1; + } + return reverseString; + } +} From 6432a32fa2694ce92fe87a3d313a35e11e093b63 Mon Sep 17 00:00:00 2001 From: Tatiparthi Chenchu Jahnavi <85797034+Jahnavi998@users.noreply.github.com> Date: Sun, 13 Oct 2024 19:48:47 +0530 Subject: [PATCH 2/4] Update reverse.cs --- Algorithms/Strings/reverse.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Algorithms/Strings/reverse.cs b/Algorithms/Strings/reverse.cs index d4488ed4..17dfa141 100644 --- a/Algorithms/Strings/reverse.cs +++ b/Algorithms/Strings/reverse.cs @@ -1,34 +1,34 @@ using System; +using System.Text; namespace Algorithms.Strings; public static class ReversedString { //comment - // In this Main Method we are taking the input and calling ReverseString Method which will return reversedString and we will print in main Method + //In this Main Method we are taking the input and calling ReverseString Method which will return reversedString and we will print in main Method //comment public static void Main(string[] args) { // Sample Input : "reverse" // Sample Output : "esrever" string input= Console.ReadLine(); - string reversedString = ReverseString(input.Trim()); - Console.WriteLine(reversedString); + ReverseString(input.Trim()); } //comment - // This Method will take input as string and return the reversed string + //This Method will take input as string and return the reversed string //comment - public static string ReverseString (string input) + public static void ReverseString (string input) { - string reverseString=""; + StringBuilder reverseString= new StringBuilder(); int length = input.Length; while(length!=0) { - reverseString= reverseString+input[length-1]; + reverseString.Append(input[length-1]); length-=1; } - return reverseString; + Console.WriteLine(reverseString); } } From ba3f02f529ba0fe17f24af383ab809d8fe85c41c Mon Sep 17 00:00:00 2001 From: Tatiparthi Chenchu Jahnavi <85797034+Jahnavi998@users.noreply.github.com> Date: Tue, 15 Oct 2024 08:42:49 +0530 Subject: [PATCH 3/4] Create CountVowels.cs This method will print the count the vowels of a given string --- Algorithms/Strings/CountVowels.cs | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Algorithms/Strings/CountVowels.cs diff --git a/Algorithms/Strings/CountVowels.cs b/Algorithms/Strings/CountVowels.cs new file mode 100644 index 00000000..396d70c7 --- /dev/null +++ b/Algorithms/Strings/CountVowels.cs @@ -0,0 +1,32 @@ +using System; +namespace Algorithms.Strings; + +public static class Vowels { + // comment + // In main method we are reading the input and calling CountVowels method to count the vowels of a given string + // comment + public static void Main(string[] args) { + string input= Console.ReadLine(); + CountVowels(input.Trim()); + } + // comment + // In CountVowels Method we are printing the count of vowels in given string + // comment + public static void CountVowels(string input) + { + string vowels = "aeiouAEIOU"; + int count=0; + for(int i=0;i Date: Tue, 15 Oct 2024 08:48:00 +0530 Subject: [PATCH 4/4] Delete Algorithms/Strings/CountVowels.cs deleted this as this is coming in the same PR --- Algorithms/Strings/CountVowels.cs | 32 ------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 Algorithms/Strings/CountVowels.cs diff --git a/Algorithms/Strings/CountVowels.cs b/Algorithms/Strings/CountVowels.cs deleted file mode 100644 index 396d70c7..00000000 --- a/Algorithms/Strings/CountVowels.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -namespace Algorithms.Strings; - -public static class Vowels { - // comment - // In main method we are reading the input and calling CountVowels method to count the vowels of a given string - // comment - public static void Main(string[] args) { - string input= Console.ReadLine(); - CountVowels(input.Trim()); - } - // comment - // In CountVowels Method we are printing the count of vowels in given string - // comment - public static void CountVowels(string input) - { - string vowels = "aeiouAEIOU"; - int count=0; - for(int i=0;i