-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhrt.py
More file actions
55 lines (55 loc) · 1.1 KB
/
hrt.py
File metadata and controls
55 lines (55 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
class compare:
def __init__(self,s,t):
self.s=s
self.t=t
def cmp(self):
pass
class strcmp(compare):
def __init__(self, s, t):
super().__init__(s, t)
def cmp(self):
for i in range(min(len(self,s),len(self,t))):
if self.s[i]>self.t[i]:
return 1
elif self.s[i]==self.t[i]:
return 0
else:
return -1
class numcmp(compare):
def __init__(self, s, t):
super().__init__(s, t)
def cmp(self):
if float(self.s)>float(self.t):
return 1
elif float(self.s)==float(self.t):
return 0
else:
return -1
s=input('첫번째 문자열 입력')
t=input('두번째 문자열 입력')
num,charct=1,2
cond=num
for i in range(len(s)):
c=s[i]
if i==0 and c=='-':
continue
if c.isdigit() or c=='.':
continue
else:
cond=charct
break
if cond==num:
for i in range(len(t)):
c=t[i]
if i==0 and c=='-':
continue
if c.isdigit() or c=='.':
continue
else:
cond=charct
break
if cond==num:
p=numcmp(s,t)
else:
p=strcmp(s,t)
print(p.cmp())