Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
Bu problemi çözüyorum. Kodu yazdım. Vs 2019 da ve .NET SDK da test ettim.(.NET 5.0) çalışıyor. Ancak leetcode a yüklerken hata veriyor. İlk başta main fonksiyonun ismini "revınt" yaptım oradaki hata gitti alt satrıda başka hata verdi. Kodda mı hata var yoksa başka bir şey mi yapmam lazım?
Kod:
[CODE lang="csharp" title="Reversing Integer C#:"]using System;
namespace Reverse_Integers
{
class Program
{
static string res;
static char negX;
static void Main(string[] args)
{
res = "";
Console.Write("Type the number that is going to reverse: ");
int x = Convert.ToInt32(Console.ReadLine());
if(x == 0)
Console.WriteLine(x);
else
{
string xOne = x.ToString();
char[] xCharArray = xOne.ToCharArray();
Array.Reverse(xCharArray);
if (xCharArray[0] == '0')
xCharArray[0] = ' ';
if (x < 0)
negX = xCharArray[xCharArray.Length - 1];
else
negX = ' ';
if (negX == '-')
{
res += negX;
xCharArray[xCharArray.Length - 1] = ' ';
}
for (int i = 0; i < xCharArray.Length; i++)
res += xCharArray
;
Console.WriteLine(res);
}
}
}
}
[/CODE]