using System;
using System.Collections.Specialized;
using System.ComponentModel.DataAnnotations;
using System.Runtime.ExceptionServices;
namespace exercitiu7;
class math
{
static void Main(string[] args)
{
int firstNumber;
int secondNumber;
int thirdNumber;
PrintTextUsers();
Console.WriteLine(" type the first number");
firstNumber = int.Parse(Console.ReadLine());
Console.WriteLine("type the second number");
secondNumber = int.Parse(Console.ReadLine());
Console.WriteLine(" type the third number");
thirdNumber = int.Parse(Console.ReadLine());
Min(firstNumber, secondNumber , thirdNumber);
}
static void PrintTextUsers()
{
Console.WriteLine(" types the numbers");
}
static void Min(int firstNumber, int secondNumber, int thirdNumber)
{
var min;
if (firstNumber < secondNumber)
{
min = firstNumber;
}
if(firstNumber
{
min = firstNumber;
}
if (secondNumber < firstNumber)
{
min = secondNumber;
}
if(secondNumber < thirdNumber) {
min = secondNumber;
}
if(thirdNumber< firstNumber)
{
min = thirdNumber;
}
if(thirdNumber
{
min = thirdNumber;
}
Console.WriteLine(min);
}
}
Corectati codul , ca sa afiseze minimul a celor 3 numere
Răspunsuri la întrebare
Răspuns:
using System;
namespace exercitiu7
{
class math
{
static void Main(string[] args)
{
int firstNumber;
int secondNumber;
int thirdNumber;
PrintTextUsers();
Console.WriteLine(" type the first number");
firstNumber = int.Parse(Console.ReadLine());
Console.WriteLine("type the second number");
secondNumber = int.Parse(Console.ReadLine());
Console.WriteLine(" type the third number");
thirdNumber = int.Parse(Console.ReadLine());
Min(firstNumber, secondNumber , thirdNumber);
}
static void PrintTextUsers()
{
Console.WriteLine(" types the numbers");
}
static void Min(int firstNumber, int secondNumber, int thirdNumber)
{
if (thirdNumber < firstNumber && thirdNumber < secondNumber)
{
Console.WriteLine(thirdNumber);
}
else if (secondNumber < firstNumber)
{
Console.WriteLine(secondNumber);
}
else
{
Console.WriteLine(firstNumber);
}
}
}
}