En Büyük ve En Küçük Sayıyı Bulma

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
int s1, s2, s3, s4, s5, buyuk, kucuk;
Console.Write("Bir sayı girin : ");
s1 = Convert.ToInt32(Console.ReadLine());
Console.Write("İkinci bir sayı girin : ");
s2 = Convert.ToInt32(Console.ReadLine());
Console.Write("Üçüncü bir sayı girin : ");
s3 = Convert.ToInt32(Console.ReadLine());
Console.Write("Dördüncü bir sayı girin : ");
s4 = Convert.ToInt32(Console.ReadLine());
Console.Write("Beşinci bir sayı girin : ");
s5 = Convert.ToInt32(Console.ReadLine());
if (s1 > s2 && s1 > s3 && s3 > s4 && s4 > s5)
buyuk = s1;
else if (s2 > s3 && s3 > s4 && s4 > s5)
buyuk = s2;
else if (s3 > s4 && s4 > s5)
buyuk = s3;
else if (s4 > s5)
buyuk = s4;
else
buyuk = s5;
if (s1 < s2 && s1 < s3 && s3 < s4 && s4 < s5)
kucuk = s1;
else if (s2 < s3 && s3 < s4 && s4 < s5)
kucuk = s2;
else if (s3 < s4 && s4 < s5)
kucuk = s3;
else if (s4 < s5)
kucuk = s4;
else
kucuk = s5;
Console.WriteLine("En büyük Sayı ={0}",buyuk);
Console.WriteLine("En kücük Sayı ={0}",kucuk);
Console.ReadLine();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
int s1, s2, s3, s4, s5, buyuk, kucuk;
Console.Write("Bir sayı girin : ");
s1 = Convert.ToInt32(Console.ReadLine());
Console.Write("İkinci bir sayı girin : ");
s2 = Convert.ToInt32(Console.ReadLine());
Console.Write("Üçüncü bir sayı girin : ");
s3 = Convert.ToInt32(Console.ReadLine());
Console.Write("Dördüncü bir sayı girin : ");
s4 = Convert.ToInt32(Console.ReadLine());
Console.Write("Beşinci bir sayı girin : ");
s5 = Convert.ToInt32(Console.ReadLine());
if (s1 > s2 && s1 > s3 && s3 > s4 && s4 > s5)
buyuk = s1;
else if (s2 > s3 && s3 > s4 && s4 > s5)
buyuk = s2;
else if (s3 > s4 && s4 > s5)
buyuk = s3;
else if (s4 > s5)
buyuk = s4;
else
buyuk = s5;
if (s1 < s2 && s1 < s3 && s3 < s4 && s4 < s5)
kucuk = s1;
else if (s2 < s3 && s3 < s4 && s4 < s5)
kucuk = s2;
else if (s3 < s4 && s4 < s5)
kucuk = s3;
else if (s4 < s5)
kucuk = s4;
else
kucuk = s5;
Console.WriteLine("En büyük Sayı ={0}",buyuk);
Console.WriteLine("En kücük Sayı ={0}",kucuk);
Console.ReadLine();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public void sayilar()
{
int sayi1 = Convert.ToInt32(textBox1.Text);
int sayi2 = Convert.ToInt32(textBox2.Text);
int sayi3 = Convert.ToInt32(textBox3.Text);
int sayi4 = Convert.ToInt32(textBox4.Text);
int sayi5 = Convert.ToInt32(textBox5.Text);
int enbuyuk = sayi1;
int enkucuk = sayi1;
if (sayi2 > enbuyuk) { enbuyuk = sayi2; }
if (sayi3 > enbuyuk) { enbuyuk = sayi3; }
if (sayi4 > enbuyuk) { enbuyuk = sayi4; }
if (sayi5 > enbuyuk) { enbuyuk = sayi5; }
if (sayi2 < enkucuk) { enkucuk = sayi2; }
if (sayi3 < enkucuk) { enkucuk = sayi3; }
if (sayi4 < enkucuk) { enkucuk = sayi4; }
if (sayi5 < enkucuk) { enkucuk = sayi5; }
label1.Text = Convert.ToString(enbuyuk);
label2.Text = Convert.ToString(enkucuk);
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
sayilar();
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public void sayilar()
{
int sayi1 = Convert.ToInt32(textBox1.Text);
int sayi2 = Convert.ToInt32(textBox2.Text);
int sayi3 = Convert.ToInt32(textBox3.Text);
int sayi4 = Convert.ToInt32(textBox4.Text);
int sayi5 = Convert.ToInt32(textBox5.Text);
int enbuyuk = sayi1;
int enkucuk = sayi1;
if (sayi2 > enbuyuk) { enbuyuk = sayi2; }
if (sayi3 > enbuyuk) { enbuyuk = sayi3; }
if (sayi4 > enbuyuk) { enbuyuk = sayi4; }
if (sayi5 > enbuyuk) { enbuyuk = sayi5; }
if (sayi2 < enkucuk) { enkucuk = sayi2; }
if (sayi3 < enkucuk) { enkucuk = sayi3; }
if (sayi4 < enkucuk) { enkucuk = sayi4; }
if (sayi5 < enkucuk) { enkucuk = sayi5; }
label1.Text = Convert.ToString(enbuyuk);
label2.Text = Convert.ToString(enkucuk);
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
sayilar();
}
}
}
Yorumunuzu Ekleyin