Redux89
Hectopat
- Katılım
- 3 Ekim 2020
- Mesajlar
- 1.088
- Çözümler
- 1
Daha fazla
- Cinsiyet
- Erkek
LeetCode - The World's Leading Online Programming Learning Platform
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
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]
Son düzenleyen: Moderatör: