Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Algorithms/Strings/reverse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +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
//comment
public static void Main(string[] args)
{
// Sample Input : "reverse"
// Sample Output : "esrever"
string input= Console.ReadLine();

Check failure on line 15 in Algorithms/Strings/reverse.cs

View workflow job for this annotation

GitHub Actions / build

Converting null literal or possible null value to non-nullable type.

Check failure on line 15 in Algorithms/Strings/reverse.cs

View workflow job for this annotation

GitHub Actions / build

ReverseString(input.Trim());

Check failure on line 16 in Algorithms/Strings/reverse.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
}

//comment
//This Method will take input as string and return the reversed string
//comment

public static void ReverseString (string input)
{
StringBuilder reverseString= new StringBuilder();

Check failure on line 25 in Algorithms/Strings/reverse.cs

View workflow job for this annotation

GitHub Actions / build

int length = input.Length;
while(length!=0)

Check failure on line 27 in Algorithms/Strings/reverse.cs

View workflow job for this annotation

GitHub Actions / build

Check failure on line 27 in Algorithms/Strings/reverse.cs

View workflow job for this annotation

GitHub Actions / build

{
reverseString.Append(input[length-1]);

Check failure on line 29 in Algorithms/Strings/reverse.cs

View workflow job for this annotation

GitHub Actions / build

Check failure on line 29 in Algorithms/Strings/reverse.cs

View workflow job for this annotation

GitHub Actions / build

length-=1;

Check failure on line 30 in Algorithms/Strings/reverse.cs

View workflow job for this annotation

GitHub Actions / build

Check failure on line 30 in Algorithms/Strings/reverse.cs

View workflow job for this annotation

GitHub Actions / build

}
Console.WriteLine(reverseString);
}
}
Loading