people

Dışarıdan girilen bir sayının rakamlarını tersine çeviren program

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace Soru_Yedi
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Sayınızı Girin");
string _Sayi1 = Console.ReadLine();
int _Basamak = _Sayi1.Length;
int _Sayi = Convert.ToInt32(_Sayi1);

ArrayList _Liste = new ArrayList();

if (_Sayi > 0)
{
if (_Sayi < 10 && _Sayi >= 0) Console.WriteLine(_Sayi);

else
{
int a = 1, _Bolum = 0, _Kalan = 0;

for (int i = 0; i < _Basamak - 1; i++)
{
a = a * 10;
}

_Bolum = _Sayi / a;
_Kalan = _Sayi % a;
_Liste.Add(_Bolum);

do
{

a = a / 10;
_Bolum = _Kalan / a;
_Kalan = _Kalan % a;

_Liste.Add(_Bolum);

} while (_Kalan > 10);
_Liste.Add(_Kalan);
}

}

else Console.WriteLine("Lütfen Pozitif Sayı Giriniz");

_Liste.Reverse();

foreach (int _Veri in _Liste)
Console.Write(+_Veri);


Console.ReadLine();
}
}
}

0 yorum:

Yorum Gönder