-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathptr2.py
More file actions
56 lines (52 loc) · 993 Bytes
/
ptr2.py
File metadata and controls
56 lines (52 loc) · 993 Bytes
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
56
def fcmp(s,t):
def numcmp():
a=float(s)
b=float(t)
if a>b:
return 1
elif a==b:
return 0
else:
return -1
def strcmp():
for i in range(min(len(s),len(t))):
if s[i]<t[i]:
return -1
elif s[i]>t[i]:
return 1
else:
i+1
if len(s)<len(t):
return -1
elif len(s)>len(t):
return 1
else:
return 0
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:
return numcmp
else:
return strcmp
s,t=input('문자열 1 입력'),input('문자열 2 입력')
p=fcmp(s,t)
print(p())