-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathptr.py
More file actions
57 lines (51 loc) · 957 Bytes
/
ptr.py
File metadata and controls
57 lines (51 loc) · 957 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
57
def strcmp(s,t):
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
def numcmp(s,t):
s,t=float(s),float(t)
if s>t:
return 1
elif s==t:
return 0
else:
return -1
def fcmp(s,t):
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(s,t))