0601 Suninatas 1번
수요일팀 박민진
소스를 보면 asp 파일이라는 것을 알수 있다.
asp 파일이란 동적으로 서버에서 작동하는 페이지인데 자세한 내용은 아래의 블로그를 참고하여 공부해보았다.
https://genesis8.tistory.com/218
Replace 함수는 치환 함수이고 MID 함수는 문자열 일부를 자르는 함수이다.
따라서 해석해보면
str = Request("str") - 입력하여 요청한 값을 str이라는 변수에 저장한다.
If not str = "" Then - str 입력받은 텍스트가 아무것도 없지 않다면 코드를 실행
result = Replace(str,"a","aad") - 'a'가 있을 경우 , 'add'로 바꿔짐
result = Replace(result, "i", "in") - 'i'가 있을 경우, 'in'으로 바꿔짐
result1 = Mid(result,2,2) - 2번째 부터 2개의 문자를 가져옴
result2 = Mid(result,4,6) - 4번째 부터 2개의 문자를 가져옴
result = result1 & result2 - &는 연결 연산자로써 문자열을 합치는 기능 수행
그러므로 정답은 "ami" 이다.
str 입력 값으로 "ami"를 넣고 풀어보면
str = "ami"
result = replace(str,"a", "aad") -> result = "aadmi"
result = replace(str, "i", "in") -> result = "aadmin"
result1 = Mid(result , 2, 2) -> result1 = "ad"
result2 = Mid(result, 4, 6) -> result2 = "min"
result = result1 & result2 -> result = "admin"
이다.
참고)