20250816
class Student :
def __init__(self,a,b):
self.num = a
self.name = b
def findnum(x) :
global a
for i in range(len(a)) :
if a[i].num==x :
return i
return -1
n = int(input())
a = []
for i in range(n) :
b,c,d = input().split()
c = int(c)
x = findnum(c) # 수험번호가 c인 학생의 위치, 없다면 -1
if b=='I' and x==-1 :
a.append(Student(c,d))
elif b=='D' and x!=-1:
a.pop(x)
e = list(map(int,input().split()))
a.sort(key=lambda x : x.num)
for i in e :
f = a[i-1]
print(f.num,f.name)
# def findnum(x) :
# global a
# for i in range(len(a)) :
# if a[i][0]==x :
# return i
# return -1
#
# n = int(input())
# a = []
# e = []
# for i in range(n) :
# b,c,d = input().split()
# c = int(c)
# x = findnum(c)
# if b=='I' :
# if x==-1 :
# a.append([c,d])
# else :
# a.insert(x,[c,d])
# elif b=='D' and x!=-1 :
# a.pop(x)
# # print(a)
#
# e.append(input().split())
# a.sort(key=lambda x : x[0])
# # print(a)
#
# for i in e :
# f = ''.join(i)
#
# for i in f :
# i = int(i)
# f = a[i-1]
# print(str(f[0]),str(f[1]),sep = ' ')
https://thebook.io/080357/0315/
https://thebook.io/080357/#buyoptions
9장 클래스 내용 쭉 따라가면서 예제 실행해보기
class Person :
# def __init__(self):
# self.age = 10
# self.name = "abcd"
#
# def speak(self):
# print("age",self.age," name ",self.name)
#
# class Student(Person) :
# def __init__(self):
# super().__init__()
# self.school = "def"
# def stu_speak(self):
# super().speak()
# print("im student")
#
# b = Student()
# b.stu_speak()
# class Circle:
# def __init__(self,radius,name):
# self.radius = radius
# self.name = name
#
# def setRadius(self,r):
# self.radius = r
#
# def speak(self):
# print("radius is",self.radius," name is ",self.name)
#
# a = Circle(50,"pizza")
# a.speak()
#
# a.setRadius(500)
# a.speak()
# a = Circle()
# b = Circle()
#
# a.radius = 10
# a.name = "pizza"
#
# a.speak()
클래스(+ 상속): c언어에서의
구조체같은거 + 기능(함수)
클래스: 설계도(틀)
객체(object, 인스턴스): 물체
생성자: 객체
만들때
실행되는
함수(
for 초기값설정)
인스턴스
변수: self.name
메서드(함수): speak()
클래스
변수: 같은
클래스로
만들어진
객체끼리
공유하는
변수
a.speak() ->.~의
class Person:
# def __init__(self,x): # 생성자 : 객체를 만들때 실행되는 함수
# self.name = x
def __init__(self):
self.name = "noname"
def speak(self):
print('I\'m ', self.name)
def set_name(self, x):
self.name = x
a = Person() # Person 클래스로 a라는 객체 만들기
a.set_name("준우")
a.speak()
b = Person()
b.speak()
class Person:
# def __init__(self,x): # 생성자 : 객체를 만들때 실행되는 함수
# self.name = x
def __init__(self):
self.name = "noname"
def speak(self):
print('I\'m ', self.name)
def set_name(self, x):
self.name = x
class Student(Person):
def __init__(self):
Person.__init__(self) # 부모클래스의 생성자 실행
self.school = "noschool"
def speak(self):
Person.speak(self)
print("also I\'m Student!!!")
c = Student()
c.speak()7회 조회




