1. Ana Sayfa
  2. Nesne Tabanlı Programlama

C# Örnekleri – Girilen İfadeyi Karıştırmak

C# Örnekleri – Girilen İfadeyi Karıştırmak
1

Kullanıcının girmiş olduğu ifadedeki harflerin yerini değiştirerek yeni bir ifade elde edip sonucu ekranda yazdırıyoruz.
karisikstring

 Console.WriteLine("Bir ifade girin");
            string ad = Console.ReadLine();
            string yeni="";          
            Random r = new Random();
            int randomIndex = 0;         
            int uzunluk=ad.Length;
            for (int i = uzunluk; i > 0; i--)
            {//http://www.bilisimogretmeni.com/
                randomIndex = r.Next(0, uzunluk);
                yeni += ad[randomIndex];
                ad = ad.Remove(randomIndex, 1);             
                uzunluk=ad.Length;
            }
            Console.WriteLine(yeni);
                Console.ReadKey();
Bu İçeriğe Tepkin Ne Oldu?
Subscribe
Bildir
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

1 Yorum
Inline Feedbacks
View all comments
Yusuf Mete Cerrahoğlu

Böyle bir hata alıyorum. Acaba mavi ile çizdiğim yere ne yazmam gerekir ?