using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace B012
{
class Program
{
static void Main(string[] args)
{
int x, y, z;
Console.Write("첫번쨰 값을 입력하세요 : ");
x = int.Parse(Console.ReadLine());
Console.Write("두번쨰 값을 입력하세요 : ");
y = int.Parse(Console.ReadLine());
Console.Write("세번쨰 값을 입력하세요 : ");
z = int.Parse(Console.ReadLine());
//int max = Larger(Larger(x, y),z);
//max = Larger(max, z);
Console.WriteLine("최대값은 {0}", Larger(Larger(x, y), z));
}
private static int Larger(int x, int y)
{
//if (x > y)
// return x;
//else
// return y;
//조건 연산자 사용
return (x > y) ? x : y;
}
}
}
'C# > Foundation' 카테고리의 다른 글
014.정수를 입력받아 재귀함수를 사용하여 팩토리얼을 계산하시오 (0) | 2021.04.14 |
---|---|
013.9번 문제의 5층 피라미드 그리는 프로그램을 이용하여 n 층의 피라미드를 그리는 함수를 작성하여 3, 5, 7층의 피라미드를 그리시오 (0) | 2021.04.14 |
011.10개의 숫자를 랜덤으로 만들어서 배열에 저장하고 크기 순서대로 출력하시오 (0) | 2021.04.14 |
010. 10개의 숫자를 랜덤으로 만들어서 배열에 저장하고 평균, 최소, 최대값을 구하시오 (0) | 2021.03.25 |
009. 5층짜리 피라미드를 2중 반목문을 사용하여 그리시오 (0) | 2021.03.25 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace B012
{
class Program
{
static void Main(string[] args)
{
int x, y, z;
Console.Write("첫번쨰 값을 입력하세요 : ");
x = int.Parse(Console.ReadLine());
Console.Write("두번쨰 값을 입력하세요 : ");
y = int.Parse(Console.ReadLine());
Console.Write("세번쨰 값을 입력하세요 : ");
z = int.Parse(Console.ReadLine());
//int max = Larger(Larger(x, y),z);
//max = Larger(max, z);
Console.WriteLine("최대값은 {0}", Larger(Larger(x, y), z));
}
private static int Larger(int x, int y)
{
//if (x > y)
// return x;
//else
// return y;
//조건 연산자 사용
return (x > y) ? x : y;
}
}
}
'C# > Foundation' 카테고리의 다른 글
014.정수를 입력받아 재귀함수를 사용하여 팩토리얼을 계산하시오 (0) | 2021.04.14 |
---|---|
013.9번 문제의 5층 피라미드 그리는 프로그램을 이용하여 n 층의 피라미드를 그리는 함수를 작성하여 3, 5, 7층의 피라미드를 그리시오 (0) | 2021.04.14 |
011.10개의 숫자를 랜덤으로 만들어서 배열에 저장하고 크기 순서대로 출력하시오 (0) | 2021.04.14 |
010. 10개의 숫자를 랜덤으로 만들어서 배열에 저장하고 평균, 최소, 최대값을 구하시오 (0) | 2021.03.25 |
009. 5층짜리 피라미드를 2중 반목문을 사용하여 그리시오 (0) | 2021.03.25 |