0
Extra-terrestrials task
Hi my code is working wrong. I need to make word backwards. 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) { String vhod = Console.ReadLine(); for(int b = 0; b < (vhod.Length / 2); b++){ int end = vhod.Length - b - 1 ; Char term = vhod[end]; vhod = vhod.Replace(vhod[end], vhod[b]); vhod = vhod.Replace(vhod[b], term); } Console.WriteLine(vhod); } } }
1 ответ
0
Well I failed to do with your logic..
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)
{
string myString = Console.ReadLine();
DisplayResult(ReverseString(myString));
Console.ReadLine();
}
private static string ReverseString(string message)
{
char[] charArray = message.ToCharArray();
Array.Reverse(charArray);
return String.Concat(charArray);
}
private static void DisplayResult(string message)
{
Console.WriteLine(quot;{message}");
}
}
}