Menu



Manage

Cord > Study_Algorithm 전체 다운로드
Study_Algorithm > 10/week10_chap06_09.py Lines 75 | 1.2 KB
다운로드

                        #week10_chap06_09

import webbrowser
import time


def is_stack_full():
    global SIZE, stack, top
    if top == SIZE-1:
        return True
    else :
        return False


def is_stack_empty():
	global SIZE, stack, top
	if top == -1:
		return True
	else :
		return False


def push(data):
	global SIZE, stack, top
	if is_stack_full():
		print("스택이 꽉 찼습니다.")
		return
	top += 1
	stack[top] = data


def pop():
	global SIZE, stack, top
	if is_stack_empty():
		print("스택이 비었습니다.")
		return None
	data = stack[top]
	stack[top] = None
	top -= 1
	return data


def peek():
	global SIZE, stack, top
	if is_stack_empty():
		print("스택이 비었습니다.")
		return None
	return stack[top]


SIZE = 100
stack = [None for _ in range(SIZE)]
top = -1

if __name__ == "__main__":
	urls = ['naver.com', 'daum.net', 'nate.com']

	for url in urls:
		push(url)
		webbrowser.open('http://'+url)
		print(url, end='-->')
		time.sleep(1)

	print("방문 종료")
	time.sleep(5)

	while True:
		url = pop()
		if url is None:
			break
		webbrowser.open('http://'+url)
		print(url, end='-->')
		time.sleep(1)
	print("방문 종료")