BOJ - 3613 - Java vs C++
Updated:
def solution():
variables = str(input())
if variables.find('_') >= 0:
if variables[0] == '_':
print("Error!")
return
for i in range(len(variables)):
if "A" <= variables[i] and variables[i] <= "Z" :
print("Error!")
return
cVariable = variables.split('_')
for i in range(1, len(cVariable)):
if not cVariable[i]:
print("Error!")
return
cVariable[i] = cVariable[i][0].upper() + cVariable[i][1:]
print(''.join(cVariable))
else:
if "A" <= variables[0] and variables[0] <= "Z":
print("Error!")
return
javaVariable = []
start = 0
for i in range(0, len(variables)):
if "A" <= variables[i] and variables[i] <= "Z" :
javaVariable.append(variables[start:i].lower())
start = i
javaVariable.append(variables[start:].lower())
print('_'.join(javaVariable))
solution()
https://www.acmicpc.net/problem/3613
Leave a comment