월루를 꿈꾸는 대학생
ch5 배열 백준 알고리즘 본문
728x90
10818번
문제 - 1 페이지
www.acmicpc.net
import java.util.Scanner;
public class choi2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
int [] arr = new int [num];
int X = 0;
int Y = 0;
for(int i = 0; i < arr.length; i++)
{
arr[i] = sc.nextInt();
}
for(int i = 0; i < arr.length; i++)
{
if(i == 0)
{
X = arr[i];
Y = arr[i];
}
else
{
if(X > arr[i])
{
X = arr[i];
}
if(Y < arr[i])
{
Y = arr[i];
}
}
}
System.out.print(X + " " + Y);
}
2562번
2562번: 최댓값
9개의 서로 다른 자연수가 주어질 때, 이들 중 최댓값을 찾고 그 최댓값이 몇 번째 수인지를 구하는 프로그램을 작성하시오. 예를 들어, 서로 다른 9개의 자연수 3, 29, 38, 12, 57, 74, 40, 85, 61 이 주어
www.acmicpc.net
2577
3052
1546
8958
4344
728x90
'Programing > Java' 카테고리의 다른 글
ch6 알고리즘 (0) | 2021.03.21 |
---|---|
ch 6-1 객체지향 (0) | 2021.03.21 |
CH5 배열 (0) | 2021.03.12 |
ch 4 조건문과 반복문 _ 알고리즘 (0) | 2021.03.07 |
ch4 조건문과 반복문 (0) | 2021.03.07 |