<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel = "stylesheet" href = "../css/mystyle.css" type="text/css">
<script>
function proc1(){
names = new Array();
while(true){
input = prompt("이름을 입력하세요");
if(input == null || input.trim().length < 1)break;
names.push(input);
}
document.getElementById('result1').innerHTML = names;
}
function proc2(){
items = new Array();
str = "";
while(true){
input = prompt("수를 입력해주세요");
str += input + " "
idx = items.indexOf(input);
if(idx < 0) items.push(input);
if(items.length >= 5) break;
}
res = "입력한 수 : " + str + "<br>"
res += "배열저장 한 수 : " + items + "<br>"
document.getElementById('result2').innerHTML = res;
}
</script>
</head>
<body>
<div class = "box">
사람 이름을 계속 입력 받아 배열에 저장하고 그 저장된 이름을 출력하는 프로그램을 작성하시오.<br>
(단, 입력은 prompt 명령을 이용하고, 입력의 마지막은 공백문자를 입력하거나 "취소" 버튼을 눌렀을 때로 한다. <br>
"취소" 버튼은 null 이 입력될 때이다.)<br>
<br>
<button type = "button" onclick="proc1()">확인</button>
<div id = "result1"></div>
</div>
<div class = "box">
수를 입력받는다. (입력시 중복 될수도 안될수도 있음)<br>
서로 중복되지 않은 정수 5개를 배열에 저장한다.<br>
출력하는 프로그램을 작성하시오<br>
<br>
<button type = "button" onclick="proc2()">확인</button>
<div id = "result2"></div>
</div>
</body>
</html>
