+ 8
I have solved the extra terrestrials code coach problem in c++ and python. Any Idea of how I can solve it in C#
9 Respostas
+ 3
In the same as you done it c++, Py..
Try and share your tried code if you struck..
+ 7
Strings have no reverse function so I wanted to turn it to a char Array, then print as a new string
+ 5
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
// Get the input
string character = Console.ReadLine();
// Turn it to an array
character = character.ToCharArray();
//Reverse it
character = character.Reverse(character);
//And bring it as output
Console.WriteLine(new string(character));
}
}
}
+ 4
That's the code
+ 3
Jayakrishna Thanks
+ 2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
// Get the input
string character = Console.ReadLine();
// Turn it to an array
//You need to store in character array so
char[] chars = character.ToCharArray();
//Reverse it
//Array class has method to reverse array i.e
Array.Reverse(chars);
//now you have reversed array, make it to a string back
//And bring it as output
Console.WriteLine(new string(chars));
}
}
}
+ 2
It worked perfectly
+ 1
You're turning into a array but how can you store in string? You need to store in character array..
So
char[] ch = character.ToCharArray();
Can you explain next what you are trying? String has no reverse function...
+ 1
Abasiono Mbat ok. I understood and gave the correct code above.. With explanation added in comments...
Is that not working?