İşi bilmemek işi zorlaştırıyor. İllaki yapılır ama nerede hata yaptığımı bulamıyorum. Şimdi if'leri uzattım kendim sırayla küçükten büyüğe yazarsam çalışıyor, kendim en büyük, en küçük , orta 'yı yazarsam çalışıyor. Ama büyükten küçüğe yazınca 2.de hata veriyor bir türlü çözemedim gitti.
Arkadaşlar sonunda doğru yolu uzata uzata buldum. Bu kadar uğraşmayında uğraşmak isteyenler için kodu vereyim. Ben sadece pratik olsun diye if-else'i öğreneyim diye 1-2 saattir aynı kod üzerinde uğraşıyorum. İsteyen buyursun
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int s1, s2, s3;
int a1 = 0, a2 = 0, a3 = 0;
Console.Write("Lütfen Bir Sayı Giriniz : ");
s1 = Convert.ToInt16(Console.ReadLine());
Console.Write("Lütfen Bir Sayı Giriniz : ");
s2 = Convert.ToInt16(Console.ReadLine());
Console.Write("Lütfen Bir Sayı Giriniz : ");
s3 = Convert.ToInt16(Console.ReadLine());
// ifler
// 1. if başla.
if (s1 < s2 && s1 < s3)
{
a1 = s1;
}
else if (s2 < s1 && s2 < s3)
{
a1 = s2;
}
else if (s3 < s1 && s3 < s2)
{
a1 = s3;
}
// 1. if bitti.
// 2. if başla.
if (s1 > s2 && s1 < s3)
{
a2 = s1;
}
else if (s1 > s3 && s1 < s2)
{
a2 = s1;
}
else if (s2 > s3 && s2 < s1)
{
a2 = s2;
}
else if (s3 > s2 && s3 < s1)
{
a2 = s3;
}
// 2. if bitti.
// 3. if başla.
if (s1 > s3 && s1 > s2)
{
a3 = s1;
}
else if (s2 > s3 && s2 > s1)
{
a3 = s2;
}
else if (s3 > s1 && s3 > s2)
{
a3 = s3;
}
// 3. if bitti.
Console.WriteLine("1. {0} \n2. {1} \n3. {2}", a1, a2, a3);
Console.ReadLine();
}
}
}